External hard disk not working

Question: I have Seagate 2 TB external Hard drive(Seagate Backup Plus Slim, to be exact). When I connect it to USB 2.0 port or eSATA port, it gets started spinning and beeps 2 times. Then it keep spinning for some time. Then it gets stopped. The light doesn't glow anywhere during the process. The hard drive is just 2 months old. Also I tested it on both Ubuntu and Windows 7 and on different laptops.
Answer: When I connect it to USB 2.0 or eSATA port, it starts spinning and beeps 2 times.
It is possible that your drive is not getting enough power:

Seagate and Maxtor-brand hard drives do not contain audio speakers.
Some failure mechanisms may make a regular repeating beep from the
computer's internal speaker. This may or not be hard drive related.
Check your system documentation for an explanation of system beep
codes. If a drive failure is possible, it is always important to make
an immediate backup.

...

Troubleshooting noise issues for external drives:
External USB drive clicking and beeping can occur if the USB port does
not provide enough power to operate the drive, often a USB 1.x port,
or an unpowered USB hub. To resolve this noise, connect the drive with
both of the USB connectors (if possible), or if your drive only has
one connector, try connecting it to other USB ports on your computer.
If that does not work, connect it to a powered USB hub to ensure
enough electrical power.
The Seagate Portable, Seagate FreeAgent Go Classic, and Maxtor
OneTouch mini drives, in particular, included a USB Y-cable with two
USB connectors so that, if one USB port did not power the drive
enough, it could be connected to a second USB port.

Source Identifying and troubleshooting hard drive noise issues

External hard disk not working


Mono FormBorderStyle = None

Question: I have some application on C# which was written for .NET 2.0.
Main form has property FormBorderStyle = None.
Now I try to use Mono 2.10.8 instead of .NET 2.0, and let's see this (left - Mono, right - .NET):

In Mono I still have smaaaaall border around form. As I can understand - it's a bug of Mono. But maybe someone know workaround for this?
Answer: set the border color White like the form.

Mono FormBorderStyle = None


Is it correct "Accepting payments was never this simple and easy"

Question: Is it correct to say Accepting payments was never this simple and easy -- I am concerned about the plural + was; is that correct?
Comment: The subject is not _payments_ but _accepting_ which is singular.

When acting as subjects of a sentence, gerunds and infinitives are _always singular_ and require singular verbs.
Comment: _Simple_ and _easy_ are straight synonyms in this context. You might want to use just one or the other.
Answer:
Accepting payments was never this simple and easy.

The subject of the verb was is not payments, but the verbal accepting, which is singular. Commonly called a gerund — the -ing form of a verb functioning as a noun phrase — a verbal such as accepting can still take complements like payments or be modified by adverbs just as any verb:

Conveniently accepting payments is a big part of any successful business... — Merchant Account Solutions

When the -ing form of the verb takes a plural and can be modified by adjectives, then it is no longer a verbal, but a deverbal noun that functions as any other noun:

They reflect the investors' view that the then current earnings were only temporarily low and that they would improve as economic conditions returned to normal. In the usual case, abnormally high earnings are viewed with skepticism… — Alan E. Grunewald, Stock Valuation in Federal Taxation, 1961, 85.

The remarkable thing about gerunds is that if two or more are joined by a coordinating conjunction in the subject of a clause, they still take a singular verb if considered a single action, task, or state:

Source
Despite its plural construction, Feeling gratitude and not expressing it describes a single state, thus takes a singular verb. How a writer wishes to depict an action/state, as single or separate, determines whether the verb is singular or plural:

Washing and ironing a shirt costs US$1.10. — La Ruta Maya, Yucatán, Guatemala & Belize: A Travel Survival Kit, 1991.
Washing and ironing were hard, hot work, done under cramped conditions.  — Nancy F. Cott, Domestic Ideology and Domestic Work, Part 2, 1992, 348.
Unless you are exceedingly lucky, starting and running a small business is a very time-consuming and emotionally draining process. — U.S. News & World Report, 91 (1981), 75.
Starting a small business and running it successfully are no easy tasks. — Business Development Bank of Canada.

And no matter how many gerunds or how many objects, if the task itself is seen as one activity, then the verb is still singular:

02.01.2018 · Cleaning and maintaining swimming pools, spas, fountains, artificial waterfalls or koi ponds is hard work and requires following specific rules… — Gold Coast Pool & Spa.


How to create development sharepoint server from backup of a UAT server

Question: I have been tasked to create a new development server to be installed in a server and in a VM. I am not too well informed with how to do this. is it better to install a new sharepoint server or can i do a full farm backup of the uat from the CA?
Answer: You can install SharePoint server on a VM, then do a full farm backup from UAT farm, and restore it in your development environment.
About setting up development environment, you can refer to the following article:
Set up a general development environment for SharePoint
Answer: I would first create the dev farm following a guide like this one:
https://www.petri.com/setup-sharepoint-2013-development-environment-farm-configuration
And then using SQL Server Management Studio I would make backups of the UAT content databates and restore them to the dev SQL server. I would then drop any existing databases attached to the dev Web Applications ( by using Remove-SPContentDatabase); and then attach the restored databases (by using Mount-SPContentDatabase).
Answer: First, you have to install SharePoint on the development server. below are quick steps:

Install SQL on Dev machine if you want to set up single-server farm
Before Installing SharePoint you have to install its prerequisites.
Then Install SharePoint server, Admin account thru which you are configuring the SP should have the permission db_owner permission.
Build a Web application then either you can mount DB from the source server to target server or restore the backup file to the target server.
configure services if required.

Helpful references:
https://www.c-sharpcorner.com/article/sharepoint-server-2016-installation-and-setup/
https://www.petri.com/setup-sharepoint-2013-development-environment-farm-configuration
https://www.netiq.com/communities/cool-solutions/complete-premise-sharepoint-2016-setup-guide-simple-easy-steps-troubleshooting/


Cheat sheets and -preset settings that actually work with FFmpeg 1.0+

Question: I have looked at various cheatsheets, but they were outdated. What preset settings work well with the latest versions of FFmpeg?
I'm primarily interested in the H.264 and ProRes codecs for low, medium, and high quality presets.
Comment: I want to add very important note here, video quality are different from each preset, e.g `crf 28` preset `veryslow`  looks visually way better than `medium` preset since more complex algorithms being used to enhance image quality, so it's not matter of size only but Size and image quality.
Answer: FFmpeg does not include text file based presets and profiles anymore for libx264, i.e. what you've used with the -vpre option. These have been deprecated and removed in favor of accessing the actual x264 presets, profiles (and tunes) with the -preset, -profile:v, and -tune options. The old text files only emulated the official x264 presets and profiles, and due to several limitations could not offer the full functionality that the new system provides. It is also much easier to maintain.
Additionally, many encoders have their own separate options; also called "private options". You will have to look into the audio and video encoder options for common codecs in the FFmpeg online documentation, or check the output of ffmpeg -h full for a complete list of supported options. For example, x264 lists its options under libx264 AVOptions in the full help output.
If your ffmpeg supports -preset then any text file presets should not be used, and FFmpeg no longer comes with any other than some non-standard iPod presets. It is a common misconception that text presets can simply be copied from anywhere and used with any ffmpeg. This is untrue and will result in breakage.

Basically, the presets allow you to do the following things:
Control quality
Quality is controlled either by specifying a bitrate through -b:v (for video) or -b:a (for audio), or by specifying any other encoding method the codec might support.
For x264, there are various encoding methods, with the Constant Rate Factor method being the most sophisticated. It results in variable bitrate, but overall good quality in one single pass. CRF values range from 0 to 51, but sane values are somewhere between 19 and 26, depending on your source and what quality you want. 23 is the default, so you could for example choose 18 for "high quality" and 28 for "low quality", whatever that means for you.

ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4

x264 has other encoding methods as well, but this is out of the scope here.
Constrain the H.264 profile
These profiles define a feature set the encoder may use to match the capabilities of a certain decoder. In recent FFmpeg, use the following syntax to specify a profile, where profile could be baseline, main or high:

ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline output.mp4

For more info and when you should use which profile, see: What are the differences between H.264 Profiles?
Choose an x264 encoding preset
These presets affect the encoding speed. Using a slower preset gives you better compression, or quality per filesize, whereas faster presets give you worse compression. In general, you should just use the preset you can afford to wait for. Presets can be ultrafast, superfast, veryfast, faster, fast, medium (default), slow and veryslow. Here's an example:

ffmpeg -i input.mp4 -c:v libx264 -preset slow output.mp4

Encode lossless video
This is possible by specifying a CRF of 0, so simply use -crf 0:

ffmpeg -i input.mp4 -c:v libx264 -crf 0 output.mp4

Finally, let's talk about ProRes quickly. ProRes accepts either a fixed bitrate with -b:v, or you can specify the profile, which should be a value between 0 and 3, where the bit rates are chosen according to the profile. Higher means better:

ffmpeg -i input.mp4 -c:v prores -profile:v 0 output.mov

The ffmbc Wiki suggests that names of profiles can be used – this however fails in FFmpeg 1.0.
Answer: I did a test in which I trans-coded (using libx264 encoding to .mp4) a high quality video from a Sony camcorder using the full range of preset values (except placebo) on a range of CRF values (18, 21, 24, and 27). I wanted to know what would give me the best combination of encoding speed, output quality and file size.
For each CRF value, I gave each trans-code operation a score for its encode time (e.g., for CRF = 18, preset value ultrafast's time of 5.7 seconds got a score of 1.0, veryslow's time of 162 seconds got a 0, with all other scores scaled in between). I calculated output file size scores similarly, of course giving the smallest file the best score. I then added the two scores for a "combined" speed/size score.
For each of the four CRF values, the "veryfast" preset was the hands-down winner, with nearly perfect scores of 1.94 (for CRF 18 and 21), 1.96 (CRF 24) and 1.97 (CRF 27). I find it very curious that "veryfast" produced nearly the smallest file size every time, losing only to "veryslow" and never by much.
One difference I did notice among the various preset values was that the operating system (Windows 7) would give me different thumbnails. The faster presets would show a thumbnail several seconds into the video, where the thumbnails for the slower presets would reflect the opening frame(s) of the video. That's not important for me; what I learned was that "-preset veryfast" seems to be an easy choice.
Here are my results (as a snapshot image of an Excel spreadsheet):

Here is the Excel spreadsheet as csv text:
CRF,Preset,Seconds,score,MB,score,totalscore
18,1_ultrafast,5.7,1.00,59.5,0.09,1.09
18,2_superfast,8.4,0.98,62.3,0.00,0.98
18,3_veryfast,10.8,0.97,30.9,0.98,1.94
18,4_faster,16.0,0.93,33.5,0.89,1.83
18,5_fast,24.0,0.88,36.8,0.79,1.68
18,6_medium,29.1,0.85,34.9,0.85,1.70
18,7_slow,48.1,0.73,33.9,0.88,1.61
18,8_slower,84.9,0.49,33.0,0.91,1.40
18,9_veryslow,162.0,0.00,30.1,1.00,1.00
21,1_ultrafast,5.7,1.00,38.0,0.00,1.00
21,2_superfast,7.9,0.98,35.0,0.15,1.14
21,3_veryfast,10.0,0.97,19.0,0.97,1.94
21,4_faster,14.2,0.94,21.0,0.87,1.80
21,5_fast,19.9,0.89,23.0,0.77,1.66
21,6_medium,24.6,0.86,22.0,0.82,1.67
21,7_slow,43.1,0.72,21.0,0.87,1.58
21,8_slower,69.8,0.51,20.5,0.89,1.41
21,9_veryslow,137.3,0.00,18.4,1.00,1.00
24,1_ultrafast,5.5,1.00,24.9,0.00,1.00
24,2_superfast,7.5,0.98,21.4,0.27,1.25
24,3_veryfast,9.3,0.97,12.0,0.99,1.96
24,4_faster,13.2,0.93,14.0,0.84,1.77
24,5_fast,17.4,0.90,15.0,0.76,1.66
24,6_medium,21.0,0.87,14.4,0.81,1.67
24,7_slow,37.3,0.72,14.0,0.84,1.56
24,8_slower,62.2,0.51,13.0,0.92,1.42
24,9_veryslow,121.1,0.00,11.9,1.00,1.00
27,1_ultrafast,5.5,1.00,16.8,0.00,1.00
27,2_superfast,7.4,0.98,13.6,0.38,1.36
27,3_veryfast,9.0,0.97,8.4,1.00,1.97
27,4_faster,12.6,0.93,10.1,0.80,1.73
27,5_fast,15.8,0.90,10.4,0.76,1.66
27,6_medium,18.8,0.87,10.0,0.81,1.68
27,7_slow,34.1,0.73,9.8,0.83,1.56
27,8_slower,59.6,0.48,9.0,0.93,1.41
27,9_veryslow,109.7,0.00,8.4,1.00,1.00

Comment: Here are some great blog posts on the subjects, with tests conducted for [x264](https://write.corbpie.com/ffmpeg-preset-comparison-x264-2019-encode-speed-and-file-size/) and [x265](https://write.corbpie.com/ffmpeg-preset-comparison-x265-2019-encode-speed-and-file-size/) (results are, predictably, very different for each)
Comment: I must admit that I looked on your results with suspicion, but I've repeated the test and got v. similar results, using ffmpeg version 3.3.2-1 on a 2 min 1080p movie clip. In fact veryfast generated the smallest file size 60% of the time, and coming 2nd to veryslow 40% of the time (but not by much). From now on I'll be using veryfast for all my encodes along with a fairly low CRF value (18, 19, 20) since veryfast was only a little slower with the lower CRF values than it was with the higher ones. Thanks you've saved me lots of time. Raw data and script in comment below.
Comment: Continuing from the comment above... Here's my [raw data - CRFs 18 to 27](https://gist.github.com/mattst/2a0ff8de12e0fedb2ad72ccf7131bf71) and the Linux/UNIX [bash script](https://gist.github.com/mattst/9ffee93f5053ba59275af800f0dbd654) that I wrote to run the encodes (in case anyone wishes to run a similar test).
Comment: **These comparisons incorrectly assume that quality doesn't change.** [But it does.](https://www.reddit.com/r/ffmpeg/comments/jgz3b7/does_the_speed_setting_on_x2645_affect_visual/g9vnjtn/) That's why the bitrate "increases" for the slower presets. If the quality improved by 100000x and bitrate increased by 0.1%, wouldn't you say that's worth the tradeoff?! A proper comparison should also include a perceptual quality metric (e.g. [VMAF](https://github.com/Netflix/vmaf#vmaf---video-multi-method-assessment-fusion)). That said, I agree that `ultrafast` and `superfast` should be avoided.
Answer: Slower encoding times (i.e. presets) tend to give better quality-vs-bitrate trade-off curves.

Quality vs Bitrate for H.265 for various presets on 4K UHD video

Slower presets are better at minimizing rate for a given target quality level.  This plot was constructed using this code by combining the "VMAF vs CRF" and "bitrate vs CRF" plots from this source.Note that these curves may vary depending on the data source and video resolution.

Table of results:

-preset
BD-Rate† (%)

ultrafast
51.2

superfast
39.0

veryfast
53.5

faster
53.3

fast
50.3

medium
37.5

slow
5.3

slower
0.8

veryslow
0.0

† BD-Rate denotes the relative percentage increase in rate with respect to the reference curve (i.e., veryslow).
Each preset takes 1.3x – 2.0x the encoding time as its immediately preceding preset.
Recommendations:

-preset ultrafast for realtime applications such as streaming
-preset medium (default) for casual usage
-preset slow for long term personal storage
-preset veryslow for publishing (YouTube, Netflix, or DVD)

-preset slow is usually much better than -preset medium, and worth the 2x encode time.

Source data:
To generate the plot above, the following data was combined:

VMAF vs CRF
Bitrate vs CRF
Comment: @Foliovision That answer [incorrectly](https://superuser.com/questions/490683/1825118?noredirect=1#comment2874094_1259172) ignores the big drop in quality. Or rather, it assumes quality = CRF, which is not true, as [shown in this plot](https://i.stack.imgur.com/vG2ba.png) (quality = VMAF). Compression engineers are smarter than that answer insinuates: if a preset takes longer, it's usually because it is better on average. I try to quantify how much better in this answer, though the exact amounts will depend on the data source. My answer considers UHD 4K, but lower resolutions may be different.
Comment: @Foliovision At least for this particular data source, `fast`-`ultrafast` all gave similar results, as you noticed. If you can, I recommend running a few sample encodes on your own data source / target resolution in the same way as "Code Calamity" and I did here to account for both bitrate and perceptual quality. Generally speaking, my guess is that for most data sources, `slow` is much better than `medium`, and `medium` is much better than `ultrafast`.
Comment: Mateen, your answer contradicts the answer above which shows that veryfast preset was the best compromise for speed and file size. Has something changed in ffmpeg now offers its best fast output in superfast rather than veryfast?
Comment: The plot to which you link suggests that for quality one should not accept anything faster than Slow. In a hurry, perhaps Medium. And that other than ultrafast (which is awful), it makes little difference if one chooses fast, faster, veryfast or superfast. Is this the reality? I'm trying to make some real world decisions here on encoding presets. Thanks.


i cant find and blend a background for this render

Question: im using blender for rendering and photoshop for editing but i cant really find any background for this render and dont know how to blend a background with the subject in photoshop all i need is help to find and blend a background for this render if you can teach me how to blend a background that would be great too
Render
Answer: Find a background image on a stock image website. There many of these online, such as Adobe Stock, Dreamstime, iStock etc.  Do a search for "fantasy" illustrations. Alternatively just paint your own fantasy background image. In the example below I just chose a random fantasy type image for the sake of showing an example.
As far as blending is concerned, the following should work:

Paste your background on a new image layer, and drag it under your render layer.
Select the render layer in the layers panel, then select the white area in the image using the Magic Wand tool
Invert the selection
Add a layer mask

Example
Answer: Artists generally try to make their images interesting to get attention. That reduces your options because you need a non-offensive background which must not steal the main object role. But in Photoshop it's quite easy to flatten images to fit your purposes. You only must tinker a little more than to make a hole to the white area and insert an image to the background. That's because the background should have compatible light conditions, colors, contrast, sharpness, level of details and it must plausibly continue the scene of your image further.
Your options increase substantially if you can accept also recoloring of your own image and inserting some foreground elements which bridge the background and the foreground.
To match light conditions and colors you generally need some adjustment layers to be able to search the right combination non-destructively. Layer masks in the adjustment layers and grouping are very useful to focus the effect to a limited area.
The next is an example to have something else than a desert scene which is already used in another answer.


Does GCM need to incorporate the length of the associate data and the length of the ciphertext to be secure?

Question: What is the reason for incorporating the lengths of the associated data and ciphertext into the calculation of the authentication tag in GCM? Is it for security?
Answer: Well, if the lengths were not included, then an attacker could modify the ciphertexts (or the AAD), and still have something that would be accepted by the receiver.
Here are some of the obvious ways an attacker could do this:

He could add (or remove) trailing 0 bits (or bytes); as long as the number blocks remains constant, this would not change the tag.  Of course, this is because GCM uses an all-0 padding at the AAD and ciphertext; as designed, that's safe (because of the length block)
He could prepend a block of all 0's to the AAD (and if there is no AAD, he could do that to the ciphertext); because the polynomial that GHASH computes start with the 0 value, an initial 0 value would still result in a 0 (and thus not change the tag)
He could migrate part of the AAD to the ciphertext (or versa-visa); for example, if the AAD consists of blocks $AAD_1, AAD_2$, he could make the AAD the single block $AAD_1$, and prepend the block $AAD_2$ to the ciphertext.  Again, without the length block, this would be undetected.

Of course, it would be fairly easy to tweak how GCM worked internally so that the first two methods wouldn't work (use a padding method other than all-0's, start the polynomial with the value $H$ rather than 0); however the third attack would be harder to mitigate.
Comment: Regarding the third attack you mention, how would that work? How would the message recipient come to see $AAD_{2}$ as $CT_{1}$?
Comment: @Melab: well, you would modify the $AAD$, removing the $AAD_2$ block, and modify the ciphertext, adding the $AAD_2$ block to the start.
Comment: I'm imagining that the message that gets sent consists of the IV, additional data, the ciphertext, and the MAC concatenated together in that order, so I'm not seeing where modifications are made to perform that attack.
Comment: @Melab: with your message format, how do you decrypt?  How do you tell GCM "here's where the AAD is" and "where's where the ciphertext is"?  In any case, your format is not universal users of GCM; even if your format did make the attack inapplicable, there are other uses of GCM which it might not be


Lost Bitcoin from 2011 or 2012

Question: So I wanted to look at some pornography on the internet in either 2011 or 2012 I purchased $50 worth of Bitcoin proceeded to purchase the 29.99 internet porn but there was like $18 left over and I was very naive at the time about Bitcoin and tried and tried to get that back into my bank account not knowing that you have to sell it back so I just chalked it up as $18 gone well I was informed that Bitcoin is almost $50,000 per coin now and I know at the time they were less than a dollar a coin so I've got 18 to 20 Bitcoin out there somewhere how do I go about finding it? I remember the bank account it came from I remember using PayPal to do the transaction what do I need to do and how do I do it?
Comment: Does [I have lost my wallet, what can I do?](https://bitcoin.stackexchange.com/q/103688/5406) answer your question?
Answer: Did you just sent the $50 bitcoin into the wallet the site provided to you ? Or you had it purchased into your personal wallet before you transferred to the wallet or scan page the pornography site gave you ..
If you did sent it directly to the pornography site my friend the rest of it is gone into the site
And you you did sent it to your personal wallet before you sent the $29.99 to the site look your wallet up it's in there

Lost Bitcoin from 2011 or 2012


The speed between ImageDataLayer and LMDB data layer

Question: Caffe support LMDB data layer and ImageDataLayer.
Create LMDB database from some dataset require some time and a lot of space.
In contrast, ImageDataLayer only use a txt file which is very convenient.
My question is, is there big speed difference between these two kinds of layers?
Thank you very much!
Comment: Please remember to "accept" your favourite answer, so that StackOverflow can appropriately archive the question.
Answer: LMDB is designed for faster fetching of data from a given key value. Also the data is stored in uncompressed format, which makes it easy for the machine to just read the data and directly pass them to the GPU for processing.
In ImageDataLayer, we have to read the image details from the text file, and use OpenCV to read the image to memory. This uncompressing of image is computationally expensive.
But the best performance may not always be for the LMDB layer, it depends heavily on the configuration of the machine. Consider an example of 256 image batch size and the images of size 227x227x3. Also consider than you are using a very good GPU and a high end i8 processor machine. Here single image in LMDB format may occupy 151KB. A whole batch may occupy 37MB. If the GPU is able to perform 10 batches a second, the harddisk should have a speed of reading 370MB/s. If you are using a normal SATA or external harddisk, there will be bottlenecks on reading such large chunks of data due to the limits of the hard disk.
If caffe could not fetch data in the required speed, the bottleneck slows the whole training process even worse. At the same time, if you were reading 256 images and use multi-core version of OpenCV, the data prefetching may be handled more effectively than reading an LMDB.
The above case will not occur if you have stored the LMDB data on a SSD though!
Answer: Yes, the speed difference is indeed big. LMDB is optimized for high speed batch processing.


Will traveling to Cuba reset my ESTA?

Question: Will I be allowed back into the US if I go from Canada to Chicago (26 September), back to Canada and then Canada to Cuba (29 October to 5 November) back to Canada and then Canada to New York (28th December to January 2nd)?
Does Cuba reset the 90 day count?
Comment: OP can be a resident but not a citizen of Canada - we do not need ESTA. This makes no sense but apparently residing long enough in Canada and passing a ridiculously easy test leaches out the Bad(TM) the USA wanted to keep our with the ESTA.
Comment: What is your nationality, and are you resident in Canada?
Comment: I'm voting to put this on hold until we know more about the OP's situation as per chx's comments.
Answer: Short and bitter: No, it will not, because Cuba is considered an Adjacent Island for Visa Waiver Program purposes.
However, if you're Canadian or resident in Canada, returning to your place of residence does reset the clock.
Comment: @hippietrail the adjacent islands are defined by statute.
Comment: Please don't link to questionable reliability third party sites only .gov especially travel.gov in this case https://travel.state.gov/content/visas/en/visit/visa-waiver-program.html
Comment: @chx I'm aware of that, but I'm also not aware of any place they bother to define "Adjacent Islands" on the official site.  Last I checked, though, Cuba remained pretty firmly anchored off the coast of Florida.
Comment: Usually governments go into nitpicky levels of detail defining such things as they are probably "legal terms" or somesuch.
Answer: In law, the islands are listed specifically:

The term "adjacent islands" includes Saint Pierre, Miquelon, Cuba, the Dominican Republic, Haiti, Bermuda, the Bahamas, Barbados, Jamaica, the Windward and Leeward Islands, Trinidad, Martinique, and other British, French, and Netherlands territory or possessions in or bordering on the Caribbean Sea.

You propose to spend 33 days in the US, return to Canada, travel to Cuba, and return again to the US 93 days after your first arrival.
It doesn't really matter; your first 90 day admission stamp would have expired anyway when you arrive in the US the second time. You won't qualify for automatic revalidation. So whether you travel to Cuba or not is irrelevant.
Here is your official reminder:

When traveling to the U.S. with the approved ESTA, you may only stay for up to 90 days at a time - and there should be a reasonable amount of time between visits so that the CBP Officer does not think you are trying to live here. There is no set requirement for how long you must wait between visits.

Occasional short visits are fine. The intention is to prevent "visa runs", not to catch out tourists who are a little uncertain about "the rules".
At the border the second time, you should expect some questioning about what you were doing in Canada and Cuba, and you should be able to explain confidently. Aside from that I see no real issues with the itinerary.
Answer: Doesn't matter. Let me repost the image from https://travel.stackexchange.com/a/61835/4188 to show you a rule of thumb where you need to be out for 91 days after being in for 90:
Comment: From personal experience I know that this "rule of thumb" is not strongly enforced. 3 VWP re-entries in a row with between 4 days & 2 weeks out of the US bewteen each one, and each stay in the US between 85 & 90 days, resulted in no extra attention or trouble from US immigration.
Comment: He's not proposing to be in the US for 90 days. Not even close.

Will traveling to Cuba reset my ESTA?


Is it safe to park hired 2 wheeler near Goa beaches?

Question: I am planning to hire a 2 wheeler in Goa for 3 full days. I love to roam Goa and beaches in 2 wheeler. I can travel wherever I want and I can stay at beaches till I am satisfied. My only concern is to park hired vehicle near beaches and I can spend time without any tensions. Any good solution appreciated.
Answer: You will be surprised by the amount of two-wheelers on the streets in Goa (and India for that matter) either being driven or parked randomly wherever possible. Moreover you'll be driving a rented vehicle, be it an old moped or an even older Royal Enfield, who usually all look the same and are of little to no  commercial value. Now imagine your parked vehicle surrounded by a bunch of other similar looking ones and you'll understand that you shouldn't have to worry about it being stolen since your two-wheeler will have little or no appeal to thieves. To be even more safe make sure you rent a chain/d-lock of some kind and use it to block your vehicle in place.
Of course your mileage may vary. From personal experience, I parked a moped outside a busy club for longer than a week and found it exactly where I left it.
Answer: Yes it's safe and there is no issue regarding parking of bikes(two-wheeler) near beaches in Goa, you'll just have to take care that you are not blocking the way/road.
If you're still having doubts about the safety then there are Paid-Parking(hourly basis) areas near the beaches which are way more secure, so you can opt for them as well wherever they're available.


Why does the credit for prior year AMT exist?

Question: The ways in which the US alternative minimum tax (AMT) differs from the regular tax fall into two components: excluded deductions (e.g., state taxes) and disallowed deferrals (e.g., exercising ISOs (Incentive Stock Options)). The AMT for the deferral items can generally be clawed back in future tax years by the taxpayer through the prior year AMT credit. I see that this could avoid double taxation when the deferred gains are finally recognized by the standard tax. But why collect a tax one year only to hand it back (minus inflation) in future years? Wouldn't it be simpler to remove the AMT treatment for deferral items completely? Is this just all a complex way for the federal government to get an interest-free loan for a few years? Is there some behavior this is supposed to be incentivizing?
Answer: The 10-year revenue impact needs to be estimated for tax legislation, and AMT (Alternative Minimum Tax) on ISOs (Incentive Stock Options) addresses this by reducing the 10-year revenue loss by shifting taxes earlier. Yes, the AMT paid for ISOs is supposed to be recovered over time, but there are reasons where that becomes extremely slow or impossible: death of the taxpayer, continued ISO exercises that reduce/eliminate the MTC (Minimum Tax Credit, or the credit for prior year AMT) recovered each year, already being subject to AMT for other reasons, selling ISO shares at a loss for AMT purposes, etc. Each of those can make the 10-year number look better.
Speaking specifically to "already being subject to AMT for other reasons" - AMT was originally implemented to prevent high-earners from excluding and deducting away large portions of their income. If a taxpayer is subject to AMT without the ISOs, they may never be able to recover their MTC - perhaps by design. The ultra-wealthy can often pass on assets to heirs without needing to realize any gains (if they have more than enough assets to live on elsewhere), which could mean that those ISO shares are never subject to income taxes due to the step-up in basis. AMT is one way the IRS can increase the probability of collecting (and keeping) at least some taxes from the ultra-wealthy's ISOs.
Answer:
But, why collect a tax one year only to hand it back (minus inflation) in future years?

Applying logic and rational thinking to the tax code is often a futile exercise. Much of it is unfair and doesn't work as intended (which is one of the main complaints from the IRS to the lawmakers)

Wouldn't it be simpler to remove the AMT treatment for deferral items completely?

YES!! It absolutely would be A LOT easier. AMT credit is horribly complicated

Is this just all a complex way for the federal government to get a interest-free loan for a few years?

Perhaps. It's probably mostly inertia at this point. In order to change it, some lawmaker will have to find the time and energy to engage.

Is there some behavior this is supposed to be incentivizing

Not anymore. Due to bad law writing AMT has drifted far away from it's initial intent and even for the initial intent.
Comment: I understand your point and realize that the answer to "why" in the tax code is often frustrating. In some other cases, though, there are clear reasons for the structure, and I was curious if this was such a case.
Comment: AMT credit is a particularly nasty example of poorly conceived tax code. In some extreme cases it has driven people into bankruptcy  and they only they still own is a huge pile of unusable AMT Credit. I doubt that was the intent of the law,  but that's what it actually does.


China causing Currency War

Question: Recently there have been reports of China devaluating its currency against the U.S Dollar. I'm a layman and I am unable to understand the need for a country  devaluating  it's own currency. How would it help that country? Moreover newspapers report that this move by China could result in a currency war. So what exactly is a currency war? Please try to keep it simple, as I'm a layman in the field of economics.
Answer: Okay, in layman's words, devaluing yuan (against USD) means, Chinese made goods are cheaper in USD. On the other hand, American made goods are expensive in China as a result. China wants to keep its export competitiveness and may want to keep its 'world's factory' status. Well, South Korea may as well want to use a similar strategy to make domestically produced export goods competitive, similarly, other aisan governments considering devaluing their currencies. There would then be a currency war... hope this is as simple as you wanted to see.
Answer: To understand trade/currency conflict with China we have to look at a few of the major moving parts.

Renminbi (RMB or yuan) is fixed to the dollar, the pair trade as one unit against all other currencies. So in global trade your currency is either fixed against a standard such as gold or floated freely against each other.

I am unable to understand the need for a country devaluating it's own currency. How would it help that country?
So as the dollar gains in strength, being that the yuan is pegged to the dollar as I just explained, it also gains in strength, which means that China has to devalue its own currency so it will not gain some much strength. Why is that a bad thing for China?
A much stronger USD would end up making Chinese goods more expensive everywhere on the globe except the United States. That said, a stronger or weaker dollar has no effect on the cost of Chinese goods in dollars as the yuan is pegged to the dollar.
The action of devaluing is then done in relation to the cost of dollars relative to Euros, Yen, etcetera.
In other words, what matters to China, is the dollars relative value to its other's trading partners currencies.
So when you hear that China is engaged in a currency war, its because people take China's devaluation of its own currency as a way to gain competitive advantage in affairs of trade.
So a currency war is known as a country devaluing its own currency to gain a trade advantage over another country. Many currency wars lead to this beggar-thy-neighbor situation of one nation remedying its own economic problems by worsening the economic problems of another nation.
So as a necromancer of Stack Exchange questions, answering a three year old post and anticipating someone commenting on that fact, its good to revisit and refresh the answer to these questions because it seems that our current administration here in the United States have seen the folly of beggar-thy-neighbor currency wars and have decided to strengthen instead of weakening the USD. Unfortunately, this is leading to a decline in the global competitiveness of China.
Keep in mind that, in effect, the United States exports credit to China and imports goods and dollars back. So the real issue to be observing in order to understand this complex topic is looking at the credit underlying the trade between U.S. and China.

China causing Currency War


Implementing long asynchronous operations in synchronous way

Question: I need to implement function which involves long async operation (send request to external server and periodically check if it is done) which needs to behave like synchronous operation. I'm doing that following way:
<code>start_long_operation()
while True:
  if operation_finished():
    return
  sleep()
</code>
I wonder if this is a acceptable and if there is better solution?
Comment: Don't really understand why you'd use `while True:` with a separate `if` instead of just putting the condition in the `while` loop, but other than that, it looks fine.
Answer: Depending on the nature of the asynchronous operation, there are various existing solutions which will allow you to do this more elegantly. For example, if you're waiting for a response from a server, you can use select on the socket to wait for a reply. You can also do this on several sockets at once.
Note: You should always use a timeout when possible to avoid waiting forever in case of some kind of error. The loop mentioned in your post suffers from this as well -- you should limit the total time or the number of iterations.
Answer: You would really prefer to stay away from polling.  Synchronous operations will scale better and be easier to debug.  If you have control over the external protocol then make it sync.  I say this mostly because I think a lot of people make things async thinking that somehow improves performance when it really just makes things more difficult.
You can then make sync operations appear async to your local event loop using multiple threads of control (threads, processes, select based FSMs, whatever).  If you don't have control over the external protocol and it is really async then you have no choice but to poll.  Depending on what you think the distribution of response times will be I'd use some sort of exponential backoff with a cap for the poll period.  For most programs I'd have that external to my main event loop and have it report back via some event mechanism to my event loop.


How to contact EiC when his emails seems like auto computer generated reply

Question: One of my article is under review in reputable IEEE journal. The average time of first decision for this journal is 3 months. However, my article is under review for 6.5 months and upon my inquiry I always get same email from EiC (editor-in-chief), which looks like an auto generated email, stating we appreciate your patience and we are trying to complete the process ASAP. According to journal policy, I cannot know who is the handling Associate Editor and all inquiries should go to EiC. In the given situation how can I invoke editorial board to expedite the process? Is it fine to make a call to EiC on his personal contact number?
Comment: What does EiC mean?
Comment: @henning: "Editor in Chief"
Comment: Does the journal have a desk editor (that is, an employee of the publisher)? If so, you could try contacting him or her - the desk editor is likely to have more time, and could say something like "we've invited 3 reviewers of which 2 declined and the last review is due in ____ days".
Comment: on https://mc.manuscriptcentral.com/ the only contact person is EiC, and on the Journal website under contact us the email of other two EiC is given.
Comment: What's the name of the journal? The link you gave doesn't work (it redirects to ScholarOne).
Comment: @Allure sorry for causing confusion "mc.manuscriptcentral.com" is the central system for submitting article for IEEE journals and other publishers. I am not sharing the name as I am afraid it may cause some problem for me, and for journal and EiC reputation.
Comment: I guess, you can ask directly two EiCs with manuscript detail, something like "did you hear anything from reviewers yet?"
Answer: I suggest contacting the publisher and asking them for a status update. The publisher is likely to have more time, and should be able to provide almost as good an update. IEEE's website lists some people to contact. You might be able to find an even better contact person from the journal's website.
I'd write in the email:

Is my paper under review?
If it's under review, are there any problems (e.g. the only invited reviewers haven't responded to the invitation for 3 months, and no new ones have been invited)?
If there are problems, can you ask the EiC to look at the submission?

In a first email I wouldn't mention that I've already contacted the EiC. If they ask about that, then only I'd say I've contacted the EiC, but received what looks like an automated response.


Are you allowed to neck stall all the way to the goal?

Question: Are you allowed to lift the football onto your neck using your foot or any part other than your hand, and hold it with your neck, and then walk all the way to the goal and score?
Comment: Different trick, but the same basic question with the same answer.
Comment: The dupe's top answer is wrong there, but is correct for this question. While you must not jam (? (sorry, non-native)) the ball in play you can legally carry it with whatever body part you like as long as it's not the arm or hand and as long as you're not jamming it. (The term jam sounds wrong, but I don't know a better one.)
Answer: There's no specific rule against it, but I suspect it would be covered by Laws 12.2 and/or 12.3 of the Laws of the Game. These can be found on pages 54-56 of the linked PDF.
Law 12.2 states that players can be penalized with an indirect free kick for "playing in a dangerous manner", which is defined as:

any action that, while trying to play the ball, threatens injury to someone (including the player themself) and includes preventing a nearby opponent from playing the ball for fear of injury.

A neck stall could be considered "preventing a nearby opponent from playing the ball for fear of injury", as anyone trying to get the ball off you would risk injuring you in the process.
Law 12.3, meanwhile, states that "unsporting behaviour" is a cautionable offence. As you stated, neck stalling is not very sporting, so I suspect that any player trying it would end up getting cautioned.


Question about GFI in a house

Question: My rental house was built in 1985 and there is some kind of master GFI (for lack of a better term) in the garage that controls all the GFI outlets in the house.  I'm told all the houses are built like this now.  My property manager sent out an "electrician" to check on a light switch that wasn't working.  While there, he said he noticed the outlets in the kitchen and bathrooms were not GFI and took it upon his self to install GFI outlets.  He didn't even know enough to know they were controlled by a central GFI.  Anyway, now I have GFI outlets but also still have the GFI that controls them all.  A friend of mine said they basically cancel each other out now and that now it's unsafe!  Does anyone know how this works?  I am totally ignorant of electricity and how it works and I'm trying to explain this as best I can.  I'm really nervous because I don't want an unsafe situation.  I'm not happy with the "electrician" who did this and didn't even take 5 minutes to call and get an authorization to do the work.  He's not getting paid for it, that's for sure.  Thank you for your help and advice.
Comment: Your friend is wrong.
Comment: Can you elaborate on the "master GFCI"? To my knowledge there is no such thing as a GFCI that controls more than one circuit (they are either a GFCI outlet or a GFCI circuit breaker in the breaker box). Maybe the device in the garage is actually a whole-house surge arrester?
Comment: In what country is this located? Electrical standards and devices vary a lot around the world.
Comment: Thank you for the quick responses. The house is located in the US, California to be exact.  Regarding the "master GFCI" I'll try to explain it. The outlets in the rooms with water do not have the red tab on them.  All the houses in this tract are like this and I guess that's how new homes are made.  The GFI is not at the outlet but elsewhere.  There may be more than one for each room but they are not controlled at the outlet. I'm sure I'm making no sense at all...but it sounds like my fear that they essentially cancel each other out is unfounded.  I will ask about the new codes.  Thanks!
Answer: Your problem isn't at all what you think it is
A GFI receptacle has "line" and "load" terminals -- power comes in on the "line" hot and neutral and is fed through the GFI's internal 'switch' (it's really closer to a circuit breaker, just set up to trip on current differential between hot and neutral instead of overcurrent) both to the outlets on the front and to the "load" terminals, which allows you to daisychain lights, outlets, etal off of the "load" terminals of a single GFI and have them all protected that way.
Furthermore, your friend is wrong when he says that two GFI's in series "cancel each other out" -- the configuration of two GFI's in series is legitimate and will not cause a hazard or damage them; it's simply indeterminate which one trips on a ground fault downstream of the second GFI.  Think of it as a game of quick-draw, just with tripping GFIs -- whichever one "wins" trips first and "shoots the circuit dead" so to speak.  (A similar problem arises with regular breakers and short circuits, as well.)
But there is a problem here
However, the configuration you describe is simply impossible without violating other parts of the electrical code -- the kitchen/dining room outlets must be on dedicated small-appliance branch circuits, and the bathroom and laundry room are required to be on their own circuits as well, yet the kitchen counter outlets, bathroom outlets, and laundry room outlets (new for 2014 it appears) all must be GFCI protected.  Point your property manager and electrician at sections 210.8 and 210.11(C) of the 2014 NEC...
Comment: Code only applies to new work.   If/when code changes, there's no requirement to bring previous installations up to the new code (unless of course you're doing permitted work). The wiring in the building would only have to meet whatever code was adopted in 1985 when the building was built (unless there were renovations done between then and now).
Comment: Kitchen GFCI was 1987. Bathroom and laundry room GFCI was 1975.
Comment: @Tester101 -- agreed re: the laundry room GFCI.  The small-appliance and bathroom/laundry room separate branch circuit provisions and the application of GFCIs to kitchen countertop and bathroom receptacles are not at all new, though...
Comment: @Tester101 -- thanks for the hard data -- I don't think the OP's setup ever complied with Code, even without GFCI in the kitchen being needed, though.
Answer: I actually worked on a job pretty much identical to your situation.  In each bathroom I put a GFCI to independently protect and rewired the "master gfci" as to independently protect too.  I did this because the concept of having one "master GFCI" usually is a bad idea as they get covered up by refrigerators, shelves, or other things and the home owner has no idea.  I only use them were I can explicitly know they are easy to see and not get covered up.

Question about GFI in a house


Background for table cells in LyX

Question: The title speaks for itself - how do I choose a background color for table cells in LyX?
Comment: This isn't nearly as easy as you think it is. Short answer is that there is no easy way to do this in LyX.
Answer: Please check out the (excellent!) Embedded Objects manual that comes with Lyx (directly available from the Help menu). Section 2.11 describes in detail how to color tables, table cells, and cell backgrounds.
As Martin has already pointed out, the solution is based on colortbl:

which leads to this PDF output:
Comment: @Icoo it's a shame to choose one of your answers as Icoo gave the correct explanation and Daniel gave a great example. Would you consider merging your answers?
Comment: @Amir Rachum: Merging answers is not possible and it is quite common that a question triggers more than one good answer. Just accept the one that has been most helpful for *you*. Having to choose is both, fate and fortune, of the questioner :-)
Comment: I'm well aware of the capabilities of SE, I was merely suggesting one of you editing the other's answer into his. Nevermind, thanks!
Comment: @Amir Rachum: Ah, I see. However, simply editing Martin's answer (which is good "as is", there is no point in changing much) into mine would feel a bit like cheating on him.
Comment: Answer below is more general and LaTeX oriented. This answer is more LyXy. Read both of them and you know what to do (they cite the same document anyway).
Answer: I found this. Maybe it can help. It seems it's what you are looking for:
http://wiki.lyx.org/LyX/Tables#toc7

To create colored tables, we need the LaTeX-package colortbl, that is loaded in the preamble with the line
\usepackage{colortbl}

The color of a column is adjusted with the command
\columncolor{name of color}

inside the command >{ }. The following color names are predefined:
red, green, yellow, blue, cyan, magenta, black and white
We also define our own color with the command
\definecolor{color name}{color model}{color values}

The color model can be
cmyk: cyan magenta yellow black
rgb: red, green blue
gray
and the color values are comma separated numbers between 0 and 1 describing the factor for the corresponding color of the color model.
We can e.g. define the color "darkgreen" in the preamble with
\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}

Comment: Could you add the relevant information from the link you provided? We like answers here to be self contained.

Background for table cells in LyX


"I cannot say anything else" vs. "I cannot say nothing else"

Question:
a) I cannot say anything else.
b) I cannot say nothing else.

Are a) and b) both correct in this example?

Yes, I cannot say anything/nothing else, because I did not notice anything/nothing else.

If not, can anyone explain why?
Answer: Your b) versions are ungrammatical in standard use because they employ double negatives.

I cannot say nothing else would only be used with emphasis on the 'nothing' to assert that you do in fact have something else to say.
I cannot say anything else would require a just before anything and would emphasize anything to assert that the something else you have to say isn't just anything you say to be part of the conversation but is highly specific or relevant to the topic at hand.

If you want to use 'nothing' in these contexts you must delete the 'not':

I can say nothing else because I noticed nothing else.

Even in non-standard use, where double negatives are sometimes employed for additional emphasis, you are unlikely to encounter them in the forms you offer; the negated verbs would be contracted:

I can't say nothin else cause I di'n't see nothin else.

In my part of the country you wouldn't say even that; you'd say:

I can't say nothin else cause I ain't seen nothin else.
Comment: @Mistu4u By ***emphasizing*** it. Or "emphasizing" it. Or by emphasizing, I repeat, emphasizing it. Or by --let me make myself perfectly clear-- emphasizing it.
Comment: ...or go for the "reflexive performative utterance" format, and emphasize the fact that you can't say nothing/anything by *not in fact saying anything at all*.
Comment: @FumbleFingers The minimalization principle!
Comment: Nice answer; I always wondered why natives use double-negation even in the cases where they don't mean to say positive! I get it now; there aim is to _emphasize_ the negation, however the result becomes inconsistent. So here in another question comes to my mind, if somebody wants to emphasize the negation, how would he do that?


How do we know if a particle is moving or not?

Question: if there is only one particle in the universe, how do we know if it is moving or not?
We don't have any other object to track the distance between the two, then is it possible to determine the position of such particle?
Comment: Does this answer your question? [Can we really not tell if we are moving?](https://physics.stackexchange.com/q/423597/)
Comment: I think you answered the question in the second sentence.
Comment: The irony in this sort of question is that if there were only one particle in the Universe, there would be no one to ask the question.
Comment: By definition, whatever moves, it moves in relation to something else.
Answer: We can only say a body at motion relative to any other body(may be static).
Now if there is no body in the vicinity of body you cannot really state if the body is moving or not. Motion is a relativistic term thus to claim a body is moving you need a frame of reference, but it is not in the case of rotational motion it is only true for translational motion.
In case of rotational motion you need not to have any frame of reference, as you can observe it simply.
Answer: Your question assumes that either a body is moving or it is not. That is simply wrong. There is no absolute motion, only relative motion. The consequence is that you must define a frame of reference against which you can specify a body's position and its state of motion. Relative to the room in which I am sitting, I am not moving, but relative to a passing aeroplane I am moving- It is not a question of whether I am moving or not moving in any absolute sense, since I am simultaneously moving with respect to the plane and not moving with respect to the room.
To return to your isolated particle in space, it is not moving with respect to its own rest frame, but it is moving with respect to any other frame you would like to specify that is not its rest frame. Of course, if there were truly only a single particle, then specifying other rest frames would be a very abstract idea- you would have nothing to relate them to apart from the particle itself.


Unable to use methods from Domain Service class in WCF Ria?

Question: I am trying to build an silverlight application which takes user first name, last name, pass, email address in text boxes and then add these to the database.
For this i am using WCF Ria Services.
Steps i have followed are :
Added ADO.NET Entity Data Model and then Domain Service class in my project (in web part).
Now i have got some predefined methods in my DomainService Class like Insert, Update methods.  I know how to show data in DataGrid but its not what i want.
What i want is to customize all this for :
When user clicks the submit button then there should be method inside this like AddInfo(all parameters) which can add all the data to my sql server database {at present LocalHost}.
In simple words accessing your database through custom methods to add data in sql server using WCF Ria Services
I know it was very simple while working in .net forms and all. But how about Silverlight  & WCF ria ?
Please Suggest.
Answer: If you already have the Insert method on your Domain Service, you should be able to call from the client:
//add your new data to the context
MyDomainServiceContext.Entity.Add(myEntity); //(where "Entity" is your entity Type)
//send all the changes to the server
MyDomainServiceContext.SubmitChanges();

Answer:
In simple words accessing your database through custom methods to add
  data in sql server using WCF Ria Services

What you should do is write a custom method in server-side.
On server-side, you have a DomainService class that should inherit from LinqToEntitiesDomainService<TContext>.
Simply add a method in this class with the Invoke attribute, for example:
[Invoke]
public void AddNewUser(string name, string firstName, int age)
{
    // Put logic here to add the user to the DB
}

The logic to add a user to the database is really simple, just create a new Entity, add it to the context and call context.SubmitChanges();
When you compile the client RIA Services project, the auto-generated proxy class that correspond to your DomainService will contain your new method, and you'll be able to call it using:
yourDomainContext ctx = new yourDomainContext();
ctx.AddNewUser("dsd", "ds", 42).Completed += (sender, e) =>
{
     // Called asynchronously when the job is done
};


What's the difference between $\nabla\cdot(\rho v)$ and $\rho(\nabla\cdot v)$ as a physical intuition?

Question: I'm currently learning on substantial derivatives in fluid mechanics and kind of understand how partial derivatives $\frac{(\partial\rho)}{(\partial t)}$  and substantial derivatives $\frac{(D\rho)}{(Dt)}$ differ. However, I can't get the intuition from the vector notation of the two. What would be the good way to interpret the difference between two notations and apply it to partial and substantial derivative's difference. Is $\rho$ independent of coordinate in $\rho(\nabla\cdot v)$?
Answer:
What's the difference between $\nabla\bullet(\rho v)$ and $\rho(\nabla\bullet v)$ as a physical intuition?

Physically, we are often interested in $\rho \vec v$, where $\vec v$ is the fluid velocity field (not the particle velocity) when we want to know how much mass is flowing out of some given volume $V$ with a boundary $\partial V$.
We calculate this as an integral over area $d^2\vec A$ as:
$$
\oint_{\partial V}  \rho \vec v \cdot{d^2\vec A} \;,
$$
which can be turned into a volume integral:
$$
\int_V  \vec \nabla \cdot \left(\rho\vec v\right)d^3r\;,
$$
where you see that it is the whole thing $\rho \vec v$ that is being differentiated in the integrand: $\vec \nabla \cdot (\rho \vec v)$, which is generally different from $\rho\vec \nabla \cdot \vec v$ when $\rho$ depends on the spatial coordinates.
For example, the change in mass of a fixed volume $V$ has to come from two places: (1) any explicit change in the density with time; (2) flow of mass out of the volume with time. So we have:
$$
\frac{dM}{dt} = \int d^3r \frac{\partial \rho}{\partial t} + \int d^3r \vec \nabla \cdot \left(\rho \vec v\right)=0\;,
$$
and we set this to zero since mass (usually) can't be created out of nothing...

More generally, we are interested in $\rho \vec v$ since we often are interested in quantities per unit mass and the flow of those is usually written as:
$$
\theta \rho \vec v\;,
$$
where $\theta$ is the amount of whatever per unit mass. (e.g., if you are interested in the mass itself, $\theta=1$. e.g., if you are interested in the momentum $\theta =\vec v$.)
Comment: "Steady state" just means that the quantities like $\rho$ and $\vec v$ do not explicitly depend on *time*. It doesn't really tell you anything directly about their spatial dependence. But, for example, in steady state you know that $\frac{\partial \rho}{\partial t}=0$, so using the continuity equation you can then also say that $\vec \nabla \cdot (\rho\vec v) = 0$
Comment: Thanks i can pretty much understand now. If im right, $\nabla\bullet\rho v$ and $\rho\nabla\bullet v$ is same as 0 for incompressible, but what would two values be when it is steady state or non-steady state?
Answer: In general, using the product rule for the divergence operator $\nabla \cdot$, we have
$\nabla \cdot (\rho \vec v) = \rho \nabla \cdot \vec v + (\nabla \rho) \cdot \vec v$
We can therefore see that a necessary and sufficient condition for
$\nabla \cdot (\rho \vec v) = \rho \nabla \cdot \vec v$
is that
$ (\nabla \rho) \cdot \vec v=0$
One way (although not the only way) to achieve this is to have $\nabla \rho = 0$, which means that the fluid's density is independent of location i.e. the fluid is homogenous.
Comment: Nice explanation! thanks. Besides, I was taught that substantial derivatives are a tracking of the physical quantity by change of time while following the particle itself. Would there be a way to relate this definition to a vector notation $\rho\nabla\bullet v$? I just can't come up with the idea.


Ground loop, Notebook to PC audio daisy chain

Question: Good evening fellow electro experts,
please bear with me. My knowledge about circuits is somewhat basic.
I've recently set up an audio chain from the speaker/mic combi jack of my notebook to the line-in jack of my PC. This way, I got the notebook sound on the headset connected to the PC.
The setup was working fine until I decided to plug an monitor to the notebook (in addition to the integrated one). Unfortunately, I hear an annoying electrical noise/interference whenever hold the HDMI cable of the monitor to any port of my notebook. Not just the HDMI port either, any port.
According to my research, I might have created a ground loop but I've no idea how to fix it.
The overall setup is like this:
One outlet, one outlet strip (kind of hanging from the desk atm), PC (under desk), Notebook (on desk), PC monitor (on desk), notebook monitor (wall mounted) and a simple ethernet switch (under desk) are connected to the outlet strip. In addition to that, notebook and PC are both cable connected to the switch. Notebook audio jack / PC line-in jack are connected with a male-to-male 3.5mm cable.
Unplugging the notebook from the outlet strip and from the switch didn't make any difference.
Answer: What you need is a ground loop isoloator. I had the same problem on my TV PC for years, and this fixed it.
Answer: A high frequency current takes the path of least impedance, and the path of least impedance happens to be out of your audio jack. Use ferrite chokes (inductors) to block these high frequency signals. It's really impossible from your account to know what the source is, but you could try experimenting by using cables with built-in chokes such as the one shown below.

Or you could use one of these on your audio cable.

If the source is inside of your laptop (which is entirely possible, it happens in mine) then nothing will help.


Number of game tree nodes in HU

Question: Is there a formula to calculate every possible betting/checking outcome in Heads Up situations at a given depth (stack/BB)?
Comment: It would help if you gave a lot more specifications about the game setting. What game are you even talking about? What is the betting structure (be detailed)? In any case, there are likely at least trillions of nodes, even if you are bucketing scenarios.
Comment: This question may already be answered: http://poker.stackexchange.com/questions/78/how-do-i-calculate-expected-value-of-shoving-including-fold-equity-in-heads-up
Answer: It sounds like we're looking for game states.
Assumptions:

The game is Texas Hold 'Em
We round bets to multiples of the big blind for calculating state
We don't distinguish between raising and re-re-re-re-raising because we only care about "betting / checking outcomes."
For the sake of example, we'll assume $0.50 / $1.00 blinds with a $100 buy-in.

The formula starts to look something like this:
There are 6,497,400 card states pre-flop (52 * 51 * 50 * 49)
For each one of these, there are an additional 103,776 card states on the flop.
For each of those, there are 45 new card states on the turn, and then 44 for the river. Therefore, at showdown, there are 1,335,062,881,152,000 possible card states.
At each betting juncture, there are (stack-size / BB) possible bet sizes to be made, and (stack-size / BB) possible raises to answer with. Checking adds one more possibility. Folding ends the game and destroys the state. In our example, then, there are (100 bets + 1 check) * (100 bets) = 10,100 possible betting states pre-flop. Post-flop, every dollar that went into the pot (creating a new possible state) is a dollar that we can't bet (removing a possible state), so I think that if we don't care about the full history, every betting phase has 10,100 possible betting states.
So, while the final number of game states will vary with blinds and stack sizes, we can describe the current or final state of any game with (1335062881152000 card states * 10100 betting states) = 13,484,135,099,635,200,000 nodes.
On the one hand, I hope I've interpreted your question correctly so that I could provide you a good answer. On the other hand, if I'm correct in guessing that you're looking at using game-state nodes for some sort of analysis software, I'm betting you're gonna need a bigger hard drive. And I'll make that bet even if you're Google. :)
Comment: I think your interpretation is correct, and a good start. +1. But there's plenty of room for improvement. First, betting history is critical, each giving rise to a different node. Also, raising is very important, so I don't think it's practical to eliminate it, but some simplifications are reasonable. Also, your card states could greatly be reduced, because many of those states are virtually indistinguishable from an optimization perspective. For example, compare these 2 states: 1) Ac Kd vs 9s 8h with a flop of Qh Jd Ts. 2) Ac Kd vs 9s 8h with a flop of Qs Jc Th.
Comment: Good points on all counts. Betting history *is* critical to putting your opponent on a hand, but might not matter as much to the specific analysis being performed (e.g., from state #5734221, what is the next most likely state). The math was already gnarly, so I picked the easy interpretation of "betting / checking outcomes." :)  I thought about suit compacting, too - definitely room for an algorithmic improvement, but the node count is so large that even a truly implausible 90% reduction in card states leaves us with an unmanageable tree.
Comment: Your very first number is wrong. There are 6,497,400/4 = 1,624,350 card states pre-flop, because XY is the same hand as YX.
Comment: @TonyK Argh. You are totally right. One of these days, I'll remember that step. :)

Number of game tree nodes in HU


Why some codes can be executed by creating an object file through compiler while some codes need an interpreter to be executed?

Question: We can execute a c/cpp file by creating an object file through compilatio.But why do we need to pass java bytecodes through an interpreter to execute them?Or why we can execute python/bash files by directly interpreting them? What's the differentiating feature that makes interpreter necessary to execute java bytecodes/python files/bash files etc?
Comment: Who says it's necessary? There are design decisions that lead to different solutions for different problems.
Answer: gcj compiles Java straight to machine code. PyPy compiles Python to machine code.
I think that a compiler for Bash would be pointless, because it's a terrible language for large-scale programming, and any Bash script that reaches the point of needing a compiler should be rewritten in some other language for reliability and maintainability as well as performance reasons. But pointless isn't the same as impossible.
There are C and C++ interpreters, but I have no experience with them.
The reason Java has a standard bytecode format is not that the language can't work without bytecode. It's that it was designed to support running untrusted code delivered over the Internet, and a standard, manifestly type-safe bytecode was an efficient way to do that. (JavaScript, a totally unrelated language, never had a standard bytecode format, and it's delivered as source code instead, which adds some compilation overhead on the client side.)
Some languages are easier to compile than others. Python is pretty bad for this, because so many things are changeable at run time in ways that can't always be detected at compile time. PyPy proves properties of programs when it can; when it can't prove something, it guesses, and inserts code to check at runtime if the guess is wrong, and fall back on slower generic code. This is very complicated and makes writing a compiler for Python a daunting project. But PyPy does exist and it works. JavaScript is hard to compile for similar reasons, but good JavaScript compilers exist because there's an economic incentive for companies like Google to make them.
Answer: Interpretation and compilation are simply two different ways of implementing a programming language. They are not a property of the programming language.
Every programming language can be implemented by an interpreter and every programming language can be implemented by a compiler.
Case in point: there are interpreters for C and there are native code compilers for Java and for JVM byte code.
However, it is important to understand that all a compiler does is translate a program from one language to another language. That's it. That's all it does.
Only an interpreter can actually execute code.
So, your statement

We can execute a c/cpp file by creating an object file through compilatio.

is false. You cannot execute a C program by compiling it. You can only execute something through interpretation. If you compile a C file into, say, an x86 native object code executable file, you still haven't executed the program. You still need an interpreter to execute the program. This interpreter could be a physical CPU, but it could also be something like JPC, which is a PC emulator written in Java, running on a Java Virtual Machine, or JSLinux, which is a PC emulator written in ECMAScript, running in the browser.

But why do we need to pass java bytecodes through an interpreter to execute them?

There are two possible answers to this, depending on what, exactly you mean by that statement.
The first possible answer is: because, as I explained above, everything needs to be interpreted in order to execute it. If you want to execute JVM bytecode, you need an interpreter for JVM bytecode. If you want to execute x86 native machine code, you need an interpreter for x86 native machine code.
Note that this interpreter can be a piece of software or a piece of hardware. As mentioned above, there are software interpreters for x86 native machine code (JPC, JSLinux, QEmu, Bochs). There are also CPUs which execute JVM bytecode directly (picoJava, Jazelle DBX).
The second possible answer is: you don't have to!
You don't have to execute JVM bytecode at all. You can compile it to some other language. For example, there are compilers that can compile JVM bytecode to CIL bytecode, or to x86 native machine code (Excelsior JET, GCJ).
Furthermore, many modern JVMs (including Oracle's HotSpot and Eclipse/IBM's J9) include a native code JIT compiler, so the JVM bytecode is not necessarily interpreted. Both HotSpot and J9 with default settings will interpret the same piece of code only a limited number of times, and when that threshold is reached, instead compile it to native machine code.

Or why we can execute python/bash files by directly interpreting them?

We can execute Bash files by directly interpreting them, because someone wrote an interpreter that interprets Bash files. Nobody has written a compiler for Bash yet, but that doesn't mean it is impossible. It just means that nobody has done it yet.
Note that your characterization of Python is not actually correct. There is no Python interpreter in existence at the moment. All widely-used mainstream Python implementations have compilers:

CPython compiles Python to CPython byte code (which it then interprets),
Jython compiles Python to JVM byte code,
IronPython compiles Python to DLR Trees,
GraalPython is a strange one, it parses Python into Truffle ASTs, and then interprets the Truffle ASTs with a specializing interpreter, which is essentially equivalent to compiling the Truffle ASTs (it's related to Partial Evaluation and Abstract Interpretation (aka Supercompilation)),
PyPy is another strange one, it compiles Python to PyPy byte code, interprets that PyPy byte code, and uses a tracing compiler to compile a specialized version of the interpreter which can only interpret that one program, which is essentially equivalent to compiling the PyPy byte code (it's related to Partial Evaluation and Abstract Interpretation (aka Supercompilation)).

What's the differentiating feature that makes interpreter necessary to execute java bytecodes/python files/bash files etc?

You need an interpreter to execute something. Period. There is no way around that. Even if you just read the source code and figure out the result by hand, you are interpreting the code in your head: you are the interpreter. For native machine code, the CPU is the interpreter.
You cannot execute code without interpreting it.
If you have a program written in some language X, and you want to know what the result of that program is, there are only two things you can do:

Interpret the program with an interpreter for language X, or
Compile the program with a compiler from X to Y to some other language Y, for which you have an interpreter.

Note that you can construct a longer chain if necessary: If you have a program written in X, and you have a compiler from X to Y, but no interpreter for Y, but instead you have an interpreter for Z and a compiler from Y to Z, you can

Compile the program from X to Y, then
Compile the program from Y to Z, then
Interpret the program using your Z interpreter.

This is actually fairly common. Many new language implementations start out with a compiler from that new language to (a subset of) C, then compile C to native machine code using one of the many existing C compilers, and then execute the native machine code on the CPU.
In fact, YARV's (the most widely-used implementation of Ruby) JIT compiler is based on generating C source code, so when you "interpret" Ruby using YARV, what is actually happening is that YARV compiles Ruby to YARV bytecode, then interprets that bytecode (not Ruby). In parallel, it also keeps a counter, and when it has interpreted the same bytecode a certain number of times, it will pass the bytecode to the JIT compiler, which first compiles the bytecode into its own internal representation, then compiles that internal representation into C source code, then calls GCC, which in turn compiles that C source code into assembly code (going through a couple of additional steps actually, it first compiles C to GENERIC, then GENERIC to GIMPLE, then GIMPLE to RTL, and then RTL to assembly), then calls GAS, which compiles that assembly code into native machine code. All of that is happening when you do what you call in your question "directly interpreting code".
Whether to implement a language with a compiler, an interpreter, both, or a combination is simply a question of preference. Sometimes, the author is experienced in writing compilers but not interpreters, or the other way around.
I wrote some more about this stuff on SoftwareEngineering.SE, if you are interested: Understanding the differences: traditional interpreter, JIT compiler, JIT interpreter and AOT compiler.


Can app access the text in my default memo app?

Question: I use Samsung Galaxy S2 and store some personal data in the default memo. I have updated the phone to the latest version. Can any app just access the data in my memo?
Answer: Nope. No other 3rd party app will be able to access your data in the memo. Applications on your phone are sandboxed meaning they can't access other apps data.
Check this:
<code>> The Android Application Sandbox, which isolates your app data and code
> execution from other apps.
</code>
Comment: Thanks a lot! I want to give you 1 point but don't have 15 reputation yet. By the way, can it be possible that the words in the memo just stores in some public database in my phone then other apps can access the data through that way?
Comment: ^^ I don't think so.


Raspberry Pi car connection to laptop in the park where there is no internet

Question: I have built a small Raspberry Pi 4 car which can be controlled via my laptop. Both Raspberry Pi and Laptop are connected to my home internet. I want to take the car outside in the park. There is no internet outside in the park. So how will my Raspberry Pi receive commands from my laptop when there is no internet connection? I do not want to use hotspotting from my mobile. I have seen videos where people are using their Raspberry Pi cars outside without any internet, but I do not know how they are doing it. I will appreciate some help. Thank you
Comment: `Both Raspberry Pi and Laptop are connected to my home internet` .... that is not entirely true ... they are connected to your LAN, not to internet ... the internet connection is irrelevant ...
Answer: Your Raspberry Pi has a quite capable WiFi. You can configure it to be a hotspot (access point). When it is operating in that mode, you can connect your laptop, phone, or other devices, to its network. Bear in mind, though, that tiny network is not connected to the Internet.
Do an internet search for "Raspberry Pi wifi hotspot" to find out the config details. Retain the previous config settings somehow, though, so you can restore them to be able to reconnect the Pi to your home net.
Answer: Two LoRa modules (one for the laptop and one for the pi) should work well to control your Raspberry Pi from your laptop over a long distance, where there is no WiFi available.
Another option could be Bluetooth, but you would be limited by range.


What is the difference between "scent" and "odor"?

Question: Proper usage guidelines and examples are appreciated.
Answer: Odor has a few meanings that scent doesn't:

a characteristic, strong quality
esteem or reputation

Conversely, scent has a few meanings that are not covered by odor:

the sense of smell, or figuratively the power of detection
a trace left by an animal, or figuratively any trail that can be followed

Also, scent works as a verb, while odor doesn't.
For further details and examples, see:

Merriam-Webster: scent and odor
Wiktionary: scent and odor
The Free Dictionary: scent and odor

For finding more sample sentences, I refer you to these resources.
Comment: Also, at least in my world, a *scent* is more likely to be pleasant than an *odor*.
Comment: interesting, hadn't heard odor meaning those two things
Answer: "Scent" can be positive -- there's the scent of a skunk, but there's also the scent of a pretty girl's hair, the scent of jasmine or of honey, the scent of your favorite spice -- but "odor" is neutral-to-negative.  Try telling a woman that she exudes an interesting odor; let me know how that works out.
Metaphorically, "odor" means "characteristic" or "reputation".  They used to say "odor of sanctity" but in keeping with the generally negative connotation of the word, that phrase has disappeared, while "odor of corruption" remains.
"Scent" as a metaphor has the association of a tracking dog.  There's the "scent of mystery", the "scent of a bargain".  Someone who wants attention is "giving off a scent" and someone who is in the process of solving a puzzle is "on the scent".
I remember getting off the plane in my favorite Asian country, having brought my wife to visit for the first time.  I took a lungful of air -- a familiar, missed mix of cilantro and lemongrass and palm tree.  It had been many years and I was happy, moved, to be back.  My wife wrinkled her nose.  "Smells funny here."
That's the difference between "scent" and "odor".
Comment: Scent is very often used as a synonym for perfume or fragrance in the U.S. Your answer was excellent, I thought!
Comment: In the US?  I admit I've only lived in the US for about 40 years, but I've never heard that.  The British call (or used to call) perfume and aftershave and such "scent", but I've never heard Americans do that.
Comment: Go to any major department store in the continental U.S. What is the name of the department where perfume-like stuff is sold for women? It is often "Scent and Fragrances", or maybe just "Fine Fragrance" Department, and the products sold in that department are "scent". That's because there are lots of distinctions: In order of price/ quality (ascending): eau de Cologne, eau de toilette and then parfum  or perfume. Can't refer to all of it collectively as perfume, would be deceptive.
Answer: The Merriam-Webster entry for "odor" contains:

a. a quality of something that stimulates the olfactory organ :
scent
b. a sensation resulting from    adequate stimulation of the olfactory
  organ : smell

According to that definition, an odor can be a scent or a smell.
The dictionary then gives two examples for "odor":

The cheese has a strong odor.
This deodorant prevents bad odor from occurring.

The entry for "scent" has the following examples:

The flower has a wonderful scent.
The dogs followed the fox's scent.
The prisoner escaped because the dogs lost his scent.

Based on the definition of "odor" and on the examples, while "scent" is always associated with a living being that produces the smell, "odor" can also be associated with other smells (e.g. as the ones produced by cheese and that the deodorant prevents in the examples above).


If Rachel helped Samara, then why is Samara still killing people?

Question: In the movie "The Ring" (2002), why does Aidan say that Rachel wasn't supposed to help Samara? And if Rachel had helped Samara, then why is she still killing people? And why does making a copy of the tape and showing it to someone else, free the person from the curse?
Comment: US remakes always do that, try to over-explain things.  However, the remake of the Ring held its own on eeriness, I think.  It was just a completely different type of movie. And this is coming from a HUGE fan of Japanese horror films.  Kairo (Pulse) (http://www.imdb.com/title/tt0286751/) is my favorite horror film of all time.
Comment: Thing about the English remake of The Ring is... it takes all the mystique of the Japanese original... & tosses it straight out the window. The original doesn't make you ask 'why?' just makes sure you never watch a home video ever again ;)
Comment: I haven't seen the original one. Only the American version
Answer: Recall that Samara is murdered by her adoptive mother because the girl had a malignant spirit. Remember the scene of the horses in the cursed video? It is explained that the horses threw themselves off the cliff because Samara frightened them or forced them to do it. In itself, the girl's body was only a vessel for the evil spirit and to die she did nothing but free herself. Rachel buries her corpse so she can rest but her soul is not good and now she can spread the world.
If we go to the book (which doesn't look like the movie but can serve) Sadako has a very powerful mind that transcends time and can materialize but his soul is corrupted and only seeks evil.
In short, Samara was never good or a normal girl. Think about the last movie (very bad, by the way) where they explain the origin of Samara and who were hes parents.
Answer: The answer to all of these questions is that Samara is kind of a jerk.  Admittedly, with reason!
Aiden says Rachel isn't supposed to help Samara, because while Rachel thinks helping her will put her to rest, Aiden knows that Samara is a truly malevolent spirit, who isn't interested in being put to rest. She just wants more chaos.
I'm not sure the technical reason (haha) why making a copy of the tape would free the person from the curse, but Samara's reason was that by doing so, more people would learn of her plight.
And just because they won't die in a week doesn't mean they won't be haunted for the rest of their lives.
Answer: Sorry to bring back this old thread, but I have a more  logical answer to why she keeps killing. She was mistreated as we learned in the movie, so Rachel helped her as we also learned. At the end of the movie we pan into the copy of the video cassette and I imagine some people confused at this point.
The reason they panned in to the cassette is because she had just realized that because she made the cassette, the girl was happy with her. The only way you escape death and watch the cassette is by making a copy. Samara wants her story to be told, so when Rachel made the copy, she was happy.
At the end of the movie, it showed Rachel and her son watching it and making a copy, and her telling her son it's going to be okay. Samara keeps killing if the person that watches the tape doesn't make a copy. She wants her story to be told.
I hope I helped shine some light on the question, and wish you happy scary movies!
Answer: I know this question is old but I think that Aiden told Rachel not to help Samara because she was never meant to; those who watch can only try to survive the seven days. Though Rachel thought helping Samara would put her spirit at rest, she actually just ended up spreading the curse to Noah. Why? Because Samara was never 'normal'. In her video, she says she 'can't stop' hurting people and it's referenced a few times that she 'never sleeps', implying she was born a malevolent being- pure evil. Therefore she never sought help, retribution or for anyone to find out her true story. When Rachel grasps the copy of the tape, she realises that the reason she and Aiden are spared is because she passed the curse on, which is the only way of escaping it. In my perspective, Rachel was never freed for helping or sympathising but was rather just another tool used to spread Samara's mayhem.
Answer: No guys, the reason she didn't die was because she made Noah watch the tape, at that time she didn't know that was the way to survive. And her mother killed her because Samara made everything worse for her parents, and her '' fake'' mother who tried so bad to get a child which she couldn't, could not live with the pain of killing Samara, so she jumped after she killed her.
Answer: Other than she wanted to do more harm, she wanted a do-over, that's why she possessed Aiden's body and was calling Rachel mommy.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: I believe it could be a possibility that Samara chose not to take Rachel was the fact she was also taking the two closest people in her life already. From Rachel knowing so deeply about the girl and who she is, her taking Noah and Aidan brings forth an eternal agony from Samara. It's the ultimate agony she could put someone through aside from just killing them. This is something that will sit with Rachel for the rest of her life, and she knows exactly who is behind it. Unlike the families of anyone else she has killed.


Existing file as attachment in visualforce component

Question: This time I would like to ask if anyone was able to add existing document/attachment(PDF) to visualforce template as file attachment?
Of course I mean add as part of logic in template(component). This file must be picked dynamically(there is query for this) but the problem is:
How add it as attachment?
Did any of you implemented something like this?
Comment: How are the templates being used? If you are sending them out from Apex, it would be fairly straightforward to convert attachments to be ready for email. I don't think it is possible from within the template, though...
Comment: The idea is to have "smart template", workflow should send it - because of limits
Comment: `Apex` can get around limits and still send as long as it is to a `User` or `Contact`. Does not count against any limit.
Answer: In Visualforce email template you can use below tag to render content into a PDF attachment in final email.
<messaging:attachment renderAs="PDF" filename="fileName.pdf">
    email attachment content goes here.
</messaging:attachment>

But if you are trying to render an already existing PDF document from say "Documents" in salesforce, you can try below steps
1) Get the content of the document by querying document.
2) Assign this document body to a property(String type) in the controller of visualforce email template. Then use the property inside above mentioned  tags.
Generally if you want more control over this kind of scenario, we go for an apex trigger and from trigger we send apex generated email. In this case you can query documents or any other object or even multiple objects and control attachment contents more precisely.
Please try below code to encode the Document body as string suitable for email attachment.It worked for me while reading text Document into apex and rendering as PDF in email,
Public class pdfContentController {
public String pdfBody{get;set;}
    public pdfContentController(){
        Document doc = [select body from document where Id = '01590000008P7xs'];
        pdfBody = EncodingUtil.urlEncode(doc.body.toString(), 'UTF-8');

    }
}

It looks like, if we are reading a PDF document into string, it may not render property because of encryption. But there are some work arounds, please check below,
https://developer.salesforce.com/forums/ForumsMain?id=906F00000009DKQIA2
Comment: I've asked because it didn't work :) Even encoded blob is not rendered properly.
Comment: Did you tried this?
Comment: I have sent attachments from triggers using email feature in trigger. But rendering existing document as PDF attachment, I haven't tried. I don't see a reason for it to not work. Please try once. Also remember that, if you are querying document content, you should be careful regarding heap limit(6MB for regular apex transactions) and (12MB for asynchronous apex transactions). If document size is exceeding this, it will fail.
Comment: I have updated answer with some code I tried.
Answer: Well, attaching a pdf file dynamically is possible or not I am not too sure. We did something on this line, but our approach was:

We had a Visualforce page, rendered as PDF and the content on it was dynamic based on its controller.
This PDF page was used as our attachment for a visualforce email template.

So this way, we managed to have dynamic content in the pdf attachment on the email. Does this help?
Comment: Yes, but this is still just creating. You see it is easy to include html content as attachment, the real problem is that pdf content/body is actual blob....
Answer: This seem to be not very easy to handle and potentially not possible. Instead I can give two options:

Use a link to the file attached to chatter post:

ContentDocument doc = [SELECT Id FROM ContentDocument WHERE Title = 'myfile'];
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + doc.id;

Use an AppExchange solution such as S-Drive so that you can generate links in your component to any sized document and append it to your template on the fly.

Hope this helps.


how to show date filter by next 5 months via expose filter in drupal?

Question: I have a content type with date fields . For date I am using date module. I have created a views in drupal 7 and using exposed filter. I need to show filter my data via month , Means I need to show months(next 5 months including current) in dropdown.
Answer: What you're wanting is Grouped Filters. It will let you set pre-defined discrete filters for your date.
Under the Views UI for your exposed data filter set Filter type to expose to Grouped Filters. You can set your arbitrary label, set your operator to is between, and Value type to An offset from the current time... in the date fields, you can use a relative PHP strtotime() format to specify a filter between the current date ("now") and 5 months into the future ("+5 month").
Comment: I need to may, june, july, aug, sep in label.
Comment: Grouped Filters will let you add fixed date ranges in addition to relative dates.