Why does [].all?{|a| a.include?('_')} return true?

Question: Why does
[].all?{|a| a.include?('_')}

return true?
Comment: Isomorphic to [Why does IQueryable.All() return true on an empty collection?](http://stackoverflow.com/questions/2195289/why-does-iqueryable-all-return-true-on-an-empty-collection)
Answer: Your code asks about the truth of the following statement: "For all elements a in the empty list, a includes the character '_'." Because there are no elements in the empty list, the statement is true. (This is referred to as vacuous truth in logic.) It might be easier to understand if you instead try to find a way to make that expression false. This would require having at least one element in the empty list which did not contain '_'. However, the empty list is empty, so no such element can exist. Therefore, the statement can't meaningfully be false, so it must be true.
Comment: The only answerer, who doesn't play role of Captain Obvious.
Answer: all? will pass every element of the array to the block {|a| a.include?('_')}, and return true if the block doesn't return false or nil for any of the elements. Since the array has no elements, the block will never return false or nil and so all? returns true.
Answer: all? returns true if the block never returns false or nil. The block never gets called, therefore it never returns false or nil and therefore all? returns true.
Answer: Even
[].all?{ false }

returns true, for the reasons explained in bcat's answer.


How do I remove the plastic at the tip of my faucet handle?

Question: My faucet handle has a plastic "lid" on the tip and I cannot remove it. I have tried prying it out, but I'm scared I will damage the plastic. Please help!!
Comment: Flat blade object, screwdriver, tweezers, butter knife.
Comment: It may be threaded hard to see in the photo. A pair of needle nose pliers open and used like a spanner wrench may help unscrew it.
Comment: A decent photo would be very much appreciated.
Comment: Your title and text say *faucet handle* but your photo shows a plastic object in your *faucet spout*. Please clarify.
Answer: It will pry out, you will need a razor knife with a heavy duty blade to start the gap to finish prying it out.
Answer: A Thin bladed regular (flat blade) screw driver will pry it out - some of them have a good pry spot - search around the side of the lid for a small indention under the top of the lid. Place the screw driver there and then pry.


How can I add parameters when creating a TableSection in C#?

Question: I have XAML code that adds a TableSection footer:
<TableSection Title="Cards1" local:Ex.FooterText="Sample description">

Can someone tell me how I can do the same for when I create this in C#. I tried this but it doesn't work at all so I assume there is a different way to do this:
var newSection = new TableSection("Cards1") {
    local:Ex.FooterText; "Sample description"
}

Answer: It looks like you're trying to use a so-called attached property. Have a look at the documentation here.
In code, you should be able to do something like this:
var newSection = new TableSection("Cards1");
Ex.SetFooterText(newSection, "Sample description");

Of course I don't know the exact attached property that you're trying to use, so this is a bit of a guess, but hopefully you can figure it out with this.
Just make sure that you put whatever is in the xmlns:local attribute in your XAML is added as a using to your C# class.


Install ImageMagick to docker

Question: I'm running a python script to manipulate pictures. I was using an ImageMagick binding for python called wand.
Here is the Dockerfile.
FROM ubuntu:latest

RUN apt update
RUN apt install python3 -y
RUN apt-get -y install python3-pip
RUN pip install pillow
RUN pip install wand

WORKDIR /usr/app/src
COPY image_converter.py ./
COPY test_image_converter.py ./

RUN python3 -m unittest test_image_converter.py

And this is the error message
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  https://docs.wand-py.org/en/latest/guide/install.html

Answer: Alright I got it thanks to this one Docker unantended installation of imagemagick
RUN DEBIAN_FRONTEND="noninteractive" apt-get install libmagickwand-dev --no-install-recommends -y

Install ImageMagick to docker


vCard sent with Twilio not properly rendered in iOS

Question: I'm trying to send a vCard to my iOS using curl, but the vCard is not properly rendered in my iPhone.
EXCLAMATION_MARK='!'
curl -X POST https://api.twilio.com/2010-04-01/Accounts/<acc>/Messages.json \
--data-urlencode "Body=Test6$EXCLAMATION_MARK" \
--data-urlencode "MediaUrl=https://mighty-health-assets.s3.amazonaws.com/vcf/James.vcf" \
--data-urlencode "From=+14155926669" \
--data-urlencode "To=+14159108243" \
-u <acc>:<token>

I tried different Content-Type and Content-Disposition with my file.
For Content-Disposition:

inline; filename="James.vcf"
attachment; filename="James.vcf"
inline; name="James"
attachment; name="James"

For Content-Type:

text/vcard
text/x-vcard
text/vcard
text/vcard; charset=utf-8; name="fileName.vcf"

The result is always the same:

I'd like to have ideas on what to try next or if you already experienced the same issue before.
Answer: Troubleshooting problem
Turns out one of the configuration was correct, and the problem I was facing was a different one.

When Twilio receives a file for the first time, it caches
If you adjust the headers accordingly it won't impact the delivery of the VCF file, because it will use the cached version
There is a way to overcome that

Twilio Caching
To remove the caching on your files or to set the appropriate cache policy, read: https://support.twilio.com/hc/en-us/articles/360024716314-How-Can-I-Change-the-Cache-Behavior-or-Message-Media-Files-
Troubleshooting I figured out that Twilio don't change cache based only on filename for VCF files, but by the file content itself, so you have to modify your file in order for it to clear the cache, not just the name.
Correct configuration
In order to get the file properly parsed by an iOS phone, you can use the same file format as attached https://mighty-health-assets.s3.amazonaws.com/vcf/James+Li.vcf
Headers
The contact card on iOS can only display the same text as of your file, so name your file with the same filename header property on Content-Type and it should work accordingly
Content-Disposition: inline; filename="<You file name>.vcf"
Content-Type: text/x-vcard
Cache-Control: no-cache


Managing Virtualbox on Ubuntu Server

Question: We have some Windows product testers that need versions of Windows to test on. I was wondering if there's a way to install Ubuntu Server, and then virtualbox, and then host these sessions over the RDP protocol simultaneously so that we could have like Tester A on Windows XP while at the same time have Tester B on Windows 8?
Can we also have an easy interface to reboot virtualbox instances if they jam up or suddenly shut down, without having to reboot the entire server?
Answer: The linux terminal server product ThinLinc version 4.0 do have support hosting VirtualBox VDI machines. It does support both persistent and shared VDI machines. The product is commercial but it is free to use up to 10 concurrent users.
For more information about VDI infrastrcture:
http://www.cendio.com/resources/docs/tag/pt04.html

Managing Virtualbox on Ubuntu Server


Penalty for "Game Over"?

Question: I'm not sure where I picked up this habit, but nowadays when I play a video game, if I ever get to the point where the screen is about to announce a "Game Over", I immediately shut off the console so that the "Game Over" doesn't register.
I think I'm trying to keep my play record immaculate, in case it keeps track of how many game overs I have or something.  My question is, is there any penalty to getting a game over in SS?  Does it keep track of your game overs anywhere, or am I just being unreasonably paranoid?
Comment: To me it would feel like cheating, and I'll still know I'd failed :P
Comment: Death Counters went away when the Zelda games moved to 3D.
Comment: I picked up the same habit when trying to get the secret ending in Link's Awakening. The one you get by finishing the game without Link (or w/e you named him) getting a single Game Over.
Comment: Oh, yeah, the Ocarina of Time Death Count, the ultimate in determining if you have "Gamer OCD" or not.
Answer: There is no such penalty for dying/getting a game over (aside from the fact that you died) in Skyward Sword. There is also no 'death counter' of any form.
Still, I don't think your paranoia is unreasonable! It is a common habit among gamers it seems.
Comment: In Final Fantasy 8, they keep a counter of how many times you flee from a battle. Battles are so annoying but because of that counter I never flee a single battle. Thank God there's no Game Over counter in Skyward Sword.
Answer: When you get a Game Over you'll respawn at the last door you went through, with six of your hearts. I don't think that it tracks the number, but if it does there's no penalty for dieing a lot. You won't get any fairies, potions, bombs, etc. that you used back though, so you may want to do that anyway. An easier way to do that is to just hit the Wii button and pick restart though, since it doesn't save until you tell it to at a save point/after a dungeon.
Comment: Not necessarily half, but 6 hearts at most.  I never died when I had less than 12 hearts so I can't say for sure if it's always 6 hearts or half up to 6 hearts.
Comment: Gah, 3 seconds too late. :(

Penalty for "Game Over"?


how to put listener on tab in android

Question: This is my code for tabs. Kindly tell me how to put listener on tab1 either through switch statement or by simple onclick listener. And this toast message is also not working
public class TabsActivity extends Activity implements OnClickListener  {

    TabHost th;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabs);

    th = (TabHost)findViewById(R.id.tabhost);

    th.setup();
    TabSpec specs = th.newTabSpec("tag1");
    specs.setContent(R.id.tab1);
    specs.setIndicator("Home");
    th.addTab(specs);

    specs = th.newTabSpec("tag2");
    specs.setContent(R.id.tab2);
    specs.setIndicator("Goup");
    th.addTab(specs);

    specs = th.newTabSpec("tag3");
    specs.setContent(R.id.tab3);
    specs.setIndicator("Delete");
    th.addTab(specs);

}

@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch(arg0.getId()){
    case R.id.tab1:
        Toast.makeText(TabsActivity.this, "Action Item 0 selected!", Toast.LENGTH_LONG).show();
    break;
case R.id.tab2:

    TextView text= new TextView(TabsActivity.this);
    text.setText("u have created a new tab");

    break;

case R.id.tab3:
    break;

}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_tabs, menu);
return true;
}
}

Answer: If you want to listener action click on a tab, you should use this:
th.setOnTabChangedListener(new OnTabChangeListener() {
    @Override
    public void onTabChanged(String tabId) {
        Toast.makeText(getApplicationContext(), "Click on tab: "+ tabId, Toast.LENGTH_SHORT).show();
    }
});

how to put listener on tab in android


What other paradigms exist besides vector/fragment/transform graphics programming?

Question: I am familiar with the basic concepts of writing vector and fragment shaders while using linear transformation matrices to describe orientations in 3D space.
But, what other paradigms exist (theoretical or not)?
Answer: Several other rendering paradigms exist aside from conventional rasterization of triangles using vertex and fragment shaders.

Ray tracing works by intersecting light rays with surfaces (triangle meshes, or more general surfaces: anything that can be tested for intersection) and then firing additional rays to gather information about lighting, shadows, reflections, etc at the intersection point. Path tracing and photon mapping are refinements of this concept.
REYES rendering subdivides all primitives into micropolygons the size of a single pixel or smaller, calculates lighting and shading per micropolygon vertex, then uses a specialized rasterizing algorithm to render the micropolygons in screen space with motion blur and depth of field.
Distance field ray-marching (also called sphere tracing) represents all primitives in terms of distance fields: 3D functions and/or volumetric textures that give the distance from any given point to the nearest surface in any direction. The distance field is used to step adaptively along a ray until it hits a surface, and can also be used for lighting effects such as ambient occlusion.

However, all rendering algorithms use linear transformation matrices. That's not part of the "paradigm" so much as it's the basic machinery for manipulating objects, the camera, etc in 3D space. It would be hard to do anything interesting without it.
Comment: Well you could live without the matrices but it would be hideously complex and wasteful. Many people who did not understand matrices attempt this regularily in stackoverflow but either end up reimplementing matrices without knowing it or ending with huge problems.
Comment: @PaulHK I mentioned that under raytracing
Comment: I heard of an alternative algebra before that does not use linear transformations, but some other theory. I can't remember what it is or any of the keywords so I don't know what to search for, so I am hoping someone might mention it here. The things you mentioned all seem to build on top of linear algebra, but I believe there are other techniques to build from.
Comment: @tru There are additional algebras such as [geometric algebra](https://en.wikipedia.org/wiki/Geometric_algebra) that supplement linear algebra with additional concepts, but I'm not aware of anything that _replaces_ linear algebra and fulfills the same purposes.
Comment: @NathanReed Thanks for the link! That might possibly be what it was. I really dislike all that symbolic mathematical jargon though. I'd much love to see it expressed with code, so I'll search for that. Thanks!
Comment: Monte carlo / Path tracing should be added to your list. Great list btw.
Comment: So you did, more coffee needed.


Creating service instance when needed

Question: I have a Controller class that maps request urls. I have an instance of class annotated with @Service. For example;
@Controller
class MainController{
  @Autowired
  private UserService userService;
  ...
}

As I know, this instance is created automatically by Spring container, because I added @Autowired but I use this instance when condition is met in the method. If the condition is not met, I do not need this instance. Thus, this declaration is overhead. I mean, I may not use it even though it is created.
I would like to create the object when it is needed. How can I do this in the code? I probably will not use @Autowired because I need a dynamic object creation. What else do I need to do?
Comment: Ths instance is not created because you have Autowired. it is created because it is a bean
Comment: Yes, so i will not include @Autowired.
Comment: If you wish to do that, then you should not declare userService as a bean and Create an instance by yourself when needed
Comment: I declare UserService class with "@Service". Then, I will remove this annotation from UserService class?
Comment: yes, `@Service` is what is making it a Spring bean. Irrespective of you use @Autowired or not it will be created by Spring.  But I don't see the point in doing so. Be default all spring beans are singletons. i.e. there will be only one instance of UserService class. So what is the issue.
Comment: Ok, then what is the point of defining instances with "@Bean" or "@Service"?. I see all examples with those annotations.
Comment: @Eric What do you mean? As been told before, `@Service`  can be used on top of a class to tell that Spring should create a bean for it. `@Bean` on the other hand can be used in a configuration class to tell Spring that it should create a bean for it.
Comment: @g00glen00b , I know that "Bean" objects are created in class anotated with "@Configuration". Can I create service instance as bean with the type prototype, not in the controller class??
Answer: You can use Setter injection. The @Autowired annotation can be used on setter methods. In the below example, when the annotation is used on the setter method, the setter will be called with the instance of FooFormatter when FooService is created:
public class FooService {

private FooFormatter fooFormatter;

@Autowired
public void setFooFormatter(FooFormatter fooFormatter) {
        this.fooFormatter = fooFormatter;
}
}

In this way you can inject you service when you call the setter method explicitly :) Hope this will help you :)
LATER EDIT
I've just found a way that might resolve your problem, it's named @Lazy.
You can use @Lazy annotation like this:

On your service class, put @Lazy annotation before the public Class XXX definition;

When declaring/autowiring a Service type in your controller context, put @Lazy annotation with @Autowired annotation on top of the declared attribute like

@Lazy
@Autowired
private FooFormatter fooFormatter;

for more info, check the link: http://www.baeldung.com/spring-lazy-annotation
Comment: so I will use this??

fooService.setFormatter(new FooFormatter);
Comment: Yeah, you can create a setter for your service and put @Autowired annotation on this. In this way you will ensure that the service will be injected when the controller will be created.
Comment: But I want to create this service instance when a specific condition is met, not when the controller is created. If it is created with the controller. It will be redundant. I mean, it will be waste of resource in memory.
Comment: How about creating the instance in getter method in Configuration? and then use this method in the controller??
Answer: You need to use @Lazy annotation with a combination of Bean Life Cycle annotations. But one thing you need to consider is the performance of your controller if you will re-create your service each time you need it, then you degradates the performance.

Creating service instance when needed


Sed for loop GNU Linux on Synology NAS

Question: I am working on a short script to search a large number of folders on a NAS for this odd character  and delete the character. I am on a Synology NAS running Linux. This is what I have so far.
#!/bin/bash

for file in "$(find "/volume1/PLNAS/" -depth -type d -name '**')";
do
  echo "$file";
  mv "$file" "$(echo $file | sed s/// )";
done

Current problem is that the Kernel does not appear to be passing each MV command separately. I get a long error message that appears to list every file in one command, truncated error message below. There are spaces in my file path and that it why I have tried to quote every variable.
mv: failed to access '/volume1/PLNAS/... UT Thickness Review ': File name too long

Comment: `find "/volume1/PLNAS/" -depth -type d -name '**' -exec bash -c 'echo mv "$1" "${1//}"' -- {} \;`
Comment: @jhnc I am not sure which part you're asking to clarify. `--` becomes $0 in the `bash -c` and the filename is `$1`
Comment: @jhnc ah, now I see what you're saying and that's a good thing to look out for. I am pretty sure that's not required here as what `find` would actually pass is `./-h`, which is ok.
Comment: @jordanm Oops. you're right. Can't happen. (`/volume1/PLNAS/.../-h` unless you use `-execdir`)
Comment: Apparently the Unicode is U+F028.

If you've got Python installed, you could do CHARS=$(python2 -c 'print u"\uF028".encode("utf8")');
sed 's/['"$CHARS"']//g'
Answer: Several issues. The most important is probably that for file in "$(find...)" iterates only once with file set to the full result of your search. This is what the double quotes are for: prevent word splitting.
But for file in $(find...) is not safe: if some file names contain spaces they will be split...
Assuming the character is unicode 0xf028 (  ) try the following:
while IFS= read -r -d '' file; do
  new_file="${file//$'\uf028'}"
  printf 'mv %s %s\n' "$file" "$new_file"
#  mv "$file" "$new_file"
done < <(find "/volume1/PLNAS/" -depth -type d -name $'*\uf028*' -print0)

Uncomment the mv line if things look correct.
As your file names are unusual we use the -d '' read separator and the print0 find option. This will use the NUL character (ASCII code zero) as separator between the file names instead of the default newline characters. The NUL character is the only one that you cannot find in a full file name.
We also use the bash $'...' expansion to represent the unwanted character by its unicode hexadecimal code, it is safer than copy-pasting the glyph. The new name is computed with the bash pattern substitution (${var//}).
Note: do not use echo with unusual strings, especially without quoting the strings (e.g. your echo $file | ...). Prefer printf or quoted here strings (sed ... <<< "$file").

Sed for loop GNU Linux on Synology NAS


Smooth (Inertial) Scrolling with SDL2?

Question: I am building SDL2 applications for macOS using C++. I need some "basic" scrolling for an app (like a web browser). I achieve that using the SDL_MouseWheel event, which gives me a fully functional "windows-like" scrolling. I am using a Macbook Pro and I want to bring the trackpad's functionality in.
Simply, I am asking for a better scrolling algorithm (Macbook's trackpad scrolling, inertial scrolling)
I know about the SDL_MultiGesture event, but I don't really know how to put things together to achieve the result I want.
Comment: Question seems a bit vague and broad in scope.  Can you narrow it down a bit, perhaps giving an example of what you currently have and explain how you want to alter the behaviour?
Comment: I want to implement inertial scrolling using SDL2 (probably with SDL_MultiGesture) and I want some help or example for that.
Answer: I ran into the same issue, and it turns out that SDL opts out of momentum scroll events by turning off the AppleMomentumScrollSupported default in the user defaults system.
You can turn this back on in your application with the following bit of Objective-C++, and your SDL_MouseWheel events will become smoothed.
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
                            [NSNumber numberWithBool:YES], @"AppleMomentumScrollSupported",
                            nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[appDefaults release];

Comment: This way doesn't seem to work anymore. See Martijn's answer below for the same thing in a style that works
Answer: Okay, here's the answer to the problem.
First of all, you will have to do it manually.
I also assume that you know SDL2 and C++.
*Note: I'm doing scrolling only for Y-Axis (you can do it for both if you want).
Firstly we will need some variables:
int    scrolling;               // flag (scrolling or not)
int    scroll_sensitivity = 40; // how fast we want to scroll
double scroll_Y = 0;            // current scrolling amount (on Y-Axis)
double scroll_acceleration;     // scrolling speed
double scroll_friction = 0.001; // how fast we decelerate
double scroll_prev_pos;         // previous event's position

After that you will need to handle the SDL_MultiGesture event:
case SDL_MULTIGESTURE:{
  if(event.mgesture.numFingers == 2){
    if(scrolling == 0){
      scrolling = 1;
      scroll_prev_pos = event.mgesture.y;
    } else{
      double dy = event.mgesture.y - scroll_prev_pos;
      scroll_acceleration = dy * 40;
      scroll_prev_pos = event.mgesture.y;
      scrolling = 1;
    }
  }
  break;
}

Also, we need to stop scrolling on SDL_FingerDown event:
case SDL_FINGERDOWN:{
  scrolling = 0;
  break;
}

Next, we want to update scroll_Y (put it in your "update" function):
if(scrolling){
  if(scroll_acceleration > 0) scroll_acceleration -= scroll_friction;
  if(scroll_acceleration < 0) scroll_acceleration += scroll_friction;
  if(abs(scroll_acceleration) < 0.0005) scroll_acceleration = 0;
  scroll_Y += scroll_sensitivity * scroll_acceleration;
  // Here you have to set your scrolling bounds i.e. if(scroll_Y < 0) scroll_Y = 0;
}

Finally, we want to render according to our scroll values:
SDL_Rect rect = {some_x, some_y + scroll_Y, some_w, some_h};
SDL_RenderCopy(renderer, some_texture, NULL, &rect);

This is it!
I have a fully working app with the above code, so I'm 100% sure that this works as supposed. If you have any problems (because it's not actual code, it's more like an algorithm) contact me. As I mentioned before, I assume that you already know good enough SDL and C++, so I believe that you are able to understand the implementation.
Also, I know that this solution can become better, so if you have anything to add / change, just say it!
Have a nice day!
Answer: For some reason, @Aleski's answer doesn't work anymore. The new way to hack this feature back on is:
[[NSUserDefaults standardUserDefaults] setBool: YES
                                       forKey: @"AppleMomentumScrollSupported"];

Smooth (Inertial) Scrolling with SDL2?


Insert non-duplicate data into a table from another table

Question: I am trying to insert a non duplicate records into a table but which doing so I am unable to insert it it gives me (0 row(s) affected). And actually the table itself is empty and I am insert new records. To ignore inserting duplicate records I am doing it in the query which I have added below.
Insert Into OrderDetails (CustomerID, CustomerName, OrderID, OrderDate, ProductID, ProductName, Unit, Price)
SELECT c.CustomerID, c.CustomerName, i.OrderID, i.OrderDate, p.ProductID, p.ProductName, p.Unit, p.Price
FROM Customers c
INNER JOIN items i ON c.CustomerID=i.CustomerID
INNER JOIN itemsDetails id ON i.OrderID = id.OrderID
INNER JOIN Products P ON p.ProductID = id.ProductID
Inner Join OrderDetails od ON c.CustomerID = od.CustomerID
where c.CustomerID != od.CustomerID

Am I Inserting correctly?
Comment: how many rows does your `select` statement alone return? You are `inserting` into `orderdetails` and you say the table is empty. The table is also in the `join` clause. Hence you will not get any rows from `select`. I suggest you remove `orderdetails` from `join`.
Comment: i think the syntax is: INSERT INTO tablename(...) VALUES
Comment: @LuckAss, nope, not when INSERT ... SELECT.
Comment: try the select statement in your DB on it's own and check if any values are returned
Comment: Tag the dbms product you're using.
Comment: @LuckAss it shows 0 records as My Orderdetails is empty and I am inserting fresh records to that table.
Comment: That WHERE clause looks suspicious...
Comment: that's the problem, if you join without any records, there are no records ;)
Comment: you need to change it, so you get records to insert ;)
Answer: try:
Insert Into OrderDetails (CustomerID, CustomerName, OrderID, OrderDate, ProductID, ProductName, Unit, Price)
SELECT c.CustomerID, c.CustomerName, i.OrderID, i.OrderDate, p.ProductID, p.ProductName, p.Unit, p.Price
FROM Customers c
INNER JOIN items i ON c.CustomerID=i.CustomerID
INNER JOIN itemsDetails id ON i.OrderID = id.OrderID
INNER JOIN Products P ON p.ProductID = id.ProductID
where c.CustomerID NOT IN (SELECT customerid FROM orderdetails)

Answer: The error lies in the two last rows of your statement:
Inner Join OrderDetails od ON c.CustomerID = od.CustomerID
where c.CustomerID != od.CustomerID

In the inner join, you require the CustomerID be the same.
In the where clause, you require the CustomerID to be different.
Remove the inner join of the table OrderDetails.


How to draw automata?

Question: I am doing some kind of composition of automata. So I want to visualize/ draw the composed automata for more clarity. I have done the coding in java. So can anyone suggest any library or tool which can be used for this. I have no idea how to do this?
Answer: graphviz is my preferred tool for doing any kind of graph based visualizations.  There are some Java wrappers written on top of it (such as grappa), but it's also simple to use from the command line if you just want to hack something together.

How to draw automata?


Recessed lighting on edge of concrete slab

Question: I am thinking of adding recessed stair riser lights (such as these) into the edge of a concrete slab I will be pouring. The lights are low-voltage landscape type lights that fit in a standard 1-gang electrical box.
I don't anticipate any problem attaching the boxes and conduit to the form before concrete is poured. I am concerned, however,  that with a 4" slab, a 2.8" wide electrical box centered on the slab height leaves only 0.6" of concrete above the box. The edge of the slab is an area where foot traffic is likely.
Is 0.6" of concrete on top of a recessed electrical box sufficient? Do I need to make the slab thicker? Are there other solutions, such as adding some kind of reinforcement over the electrical box?
Answer: You need at least 1.5" of cover for concrete that will be exposed to weather.  0.6" will just spall off.


In JavaScript, where does "constructor" come from?

Question: The following snippet of code is taken from Eloquent JavaScript.
var noCatsAtAll = {};
if ("constructor" in noCatsAtAll)
  console.log("Yes, there definitely is a cat called 'constructor'.");

I find it quite mystifying. Why does the 'if' return true?
Answer: JavaScript objects have a function called constructor which is the function that created the object's instance. It's built-in to all objects. The in operator tests for the presence of something called "constructor" in the instance of your dictionary, so it returns true. The same thing would happen if you tested for length, for example.
Answer: All instances of Object have a constructor property that specifies the function that constructs the Object's prototype.
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object#Properties_2
The in operator looks at all properties, including inherited ones. If you only want to see the properties on the object itself, you can use hasOwnProperty:
var a = {};
"constructor" in a; // true
a.hasOwnProperty("constructor"); // false

Note that while the in operator sees "constructor", a for (key in a) loop wouldn't. This is because the "constructor" property is non-enumerable.
Answer: It is the constructor of the Object type.  A reference to the constructor function is available directly on that property ("constructor") of an object (it applies to constructors you write too).
In turn, the names of properties present are in objects.
Answer: constructor is a method of Object.  You can find the constructor method throughout all objects unless you modify it. The in operator will find methods through the prototype chains. Which is is why it's recommended to use hasOwnProperty to test for properties in your own objects.
    var noCatsAtAll = {};
    if ("constructor" in noCatsAtAll)
      console.log("Yes, there definitely is a cat called 'constructor'.");

    if ('constructor' in Object)
       console.log("Yes, there is also a method called constructor");

    var noCon = Object.create(null); // create a completetly empty object
    console.log('constructor' in noCon); // false

    function hasConstructorToo() {}

    console.log('constructor' in hasConstructorToo) // true
    console.log('constructor' in []); // true

http://jsfiddle.net/Xsb3E/3`


Open downloaded file automatically

Question: Chrome remote desktop has a great setup experience
You click a button to download a file and when it is finished, it has an accept & install button that opens the file.
It shows a dialog like this:

It also knows if you cancel or delete the download like this:

And it knows when the file is finished downloading
How could I do this?
Answer: Since to use "Chrome remote desktop" you have to download its chrome extension it can use the extension APIs to access the downloads.
https://developer.chrome.com/docs/extensions/reference/downloads

Open downloaded file automatically


Cronjob for screenshots not working

Question: I'm trying to schedule a Python script which takes a screenshot every minute and stores it in a folder with that day's date and time.
import os
from datetime import datetime

path = "/home/user/Desktop/screenshots/"

today = datetime.today().strftime('%d-%m-%Y')
time = datetime.now().time().strftime('%H-%M-%S')

os.chdir(path)

try:
    os.mkdir(today)
except:
    pass

os.chdir(today)
os.system("scrot '" + time + ".png'")

I'm using a cronjob to run this script every minute.
Line added in crontab file:
* * * * * /usr/bin/python3 /home/user/Desktop/screenshots/screenshotTake.py

This is what gets outputted to the syslogs:
Dec 14 11:34:02 username CRON[7668]: (user) CMD (/usr/bin/python3 /home/user/Desktop/screenshots/screenshotTake.py)
Dec 14 11:34:02 username CRON[7667]: (CRON) info (No MTA installed, discarding output)

Now, the folder gets created alright, but there are no screenshots being saved. I tried logging some text into a log file but again, the logs.txt file got created but no text got written in the file.
I realise that creating a python script and running a simple scrot command might be an overkill but I tried doing this with a shell script and the result was the same. Folder gets created, but no screenshots are saved. Also tried using the pyscreenshot library but same result.
Comment: *scrot* has no way to know what to take a screenhsot of. May be add an env var with a DISPLAY value.
Comment: you can simply do with `* * * * * DISPLAY=:0 /usr/bin/scrot "/home/user/Desktop/screenshots/$(date +'\%d-\%m-\%Y \%T').png"`
Comment: But I need to be able to run a python script as I want to be able to do some processing on the screenshots upon being captured. Any idea why it's not taking screenshots when its clearly being run(folders get created)?
Comment: I don't know much python but I believe it's because your script not able to find `scrot` commamd and you need to provide full path of that, maybe something like `os.system("/usr/bin/scrot '" + time + ".png'")`?
Comment: No man, I just tried adding the absolute path in the python script and it still won't work. As I mentioned earlier, I even tried using a python library called pyscreenshot and it still didn't work so I'm pretty sure the issue is not related to the script not being able to find the `scrot` command.
Answer: I'm having the same trouble. I find that the problem occurred because we don't say the display that the script should use. In your case I suggest that try put DISPLAY=:0 in the call to the system function.
os.system("DISPLAY=:0 scrot '" + time + ".png'")

my script is shorter than yours, but have same effects. I save in /bin/take-screenshot
#!/bin/sh
mkdir -p $HOME/.logger/$(date +'%Y%m%d')/screenshots
DISPLAY=:0 import -window root $HOME/.logger/$(date +'%Y%m%d')/screenshots/$(date +'%H%M').png

and my cronjob is
*/5 * * * 1-5 /bin/take-screenshot

References: Scrot: A Command Line Tool to Take Desktop/Server Screenshots Automatically in Linux

Cronjob for screenshots not working


Alternative definition of simple connectedness

Question: Today in (what can typically be called a Calc III) class, our lecturer gave us the following definition :

Lecturers Definition of Simple Connectedness : A simple connected region in the plane is a connected region $D$ such that every simple closed curve in $D$ encloses only points in $D$

This isn't really a rigorous definition, what I'm assuming the lecturer means is that the plane is $\mathbb{R}^2$ with the usual metric topology. An $D \subseteq \mathbb{R}^2$ is connected.
But the only definition I know of simple connectedness is the following. A topological space $X$ is simply connected if it is path-connected and $\pi_1(X, p) = \{[c_p]\}$. (i.e. the fundamental group of $X$ is tribial)
So is the usual definition of simple-connectedness above equivalent to my lecturer's definition? I don't think so.
Take $\mathbb{S}^1$ as an example, $\mathbb{S}^1$ is path-connected and hence connected and it is very well known theorem that $\pi_1(\mathbb{S}^1) = \mathbb{Z}$ and hence $\mathbb{S}^1$ is not simply connected.
But by the definition my lecturer has given quoted above, (if encloses means contains) if we take $D = \mathbb{S}^1$, then "every simple closed curve in $D$" corresponds to paths around the perimeter of the circle with the same starting and ending points, and hence only contains points in $D$ and is simply connected.
So is my lecturer's definition wrong? I think so.
Comment: I think that "contains" means "contains in its interior" (as in "the unit circle *contains* the unit disk"). I think this is a terrible definition, but that's another matter. (For one thing...how do you define the interior? And how do you know that a simple closed curve *has* an interior. (OK, without using the Jordan Curve Theorem...))
Comment: I saw this definition and a similar question before at MSE (https://math.stackexchange.com/questions/2212392/simply-connected-domain-of-the-plane-and-the-jordan-curve-theorem) and I agree, it is quite bad).  It is equivalent to the standard one, but it takes some effort to prove this. One proof uses Alexander duality, which is quick, but an overkill.
Comment: I do not even understand your lecturer's definition. What would it mean for a curve to be in $D$ and yet not to contain only points in $D$?
Comment: @JohnHughes Sorry replace "contains" with "encloses" that was the definition given. I've edited the OP
Comment: Right...if we're in Calc 3, and trying to prove Green's Theorem or something, assuming Alexander Duality may be ... just a little tiny bit out of order. :)
Comment: There's no way around it, your lecturer's definition presupposes an intuition of an important theorem of topology which is known as the Jordan Curve Theorem. In fact, I'm not sure how one can possibly teach Green's Theorem in Calc III without making that presupposition.
Answer: Your instructor's definition qualifies as "morally wrong but technically correct". More precisely: It is morally wrong since this is not at all how one defines simple connectivity in general (even for non-planar surfaces). It is however, useful to teaching purposes, since "students understand it much better this way". (Which is what an elementary school teacher said when asked why was she teaching students to add numerator to numerator and denominator to denominator while explaining the addition of fractions.) Nevertheless, this definition is equivalent to the standard one, but proving this goes well beyond a Calc-III class. Here is a sketch of one possible proof:
Suppose that $S$ is a connected planar surface such that every Jordan curve $J\subset S$ bounds a disk contained in $S$. I will think of $S^2$ as the 1-point compactification of $R^2$, $S^2=R^2 \cup \{\infty\}$ (use the stereographic projection.)  Let us prove that
$E=S^2 -  S$ is connected. Suppose not. Take a partition of $E$ in two disjoint nonempty closed subsets $E= A\sqcup B$. Let $\chi: E\to \{0,1\}$ be the characteristic function of $A$. Now, use the Tietze-Urysohn extension theorem (which you may learn in an undergraduate general topology class) to extend $\chi$ to a continuous function $f: S^2\to {\mathbb R}$. Modify the extension (using the smooth approximation theorem) to make it smooth in $S$. (I still call the new function $f$.) Use Sard's regular value theorem to find $t\in (0,1)$, a regular value of $f$. Then $f^{-1}(t)$ is a compact 1-dimensional submanifold $M\subset S$. Each component $J$ of $M$ is a Jordan curve. At least one of these curves, $J$, will separate $A$ from $B$, just by the intermediate value theorem (Calc-I - finally I can quote something that you had seen before). Therefore, $J$ cannot bound a disk in $S$. A contradiction. Thus, $E=S^2 -S$ is connected. Now we use some algebraic topology (which you are very unlikely to see as an undergraduate). (a) Use Alexander duality to conclude that $H_1(S)=0$. (b) Prove that $\pi_1(S)$ is free (as for any noncompact connected surface: see here). (c) Use the Hurewicz theorem to conclude that $\pi_1(S)$ is trivial since $H_1(S)$ is isomorphic to the abelianization of $\pi_1(S)$.
Now, you are done proving that your instructor's definition implies that $S$ is simply connected in the usual sense. For the converse, you can use, for instance, the Riemann mapping theorem (which you might see in an undergraduate complex analysis class: if your class is called Analysis-III rather than Calc-III, then you might see the RMT quite soon, at least the statement), to conclude that every simply connected planar surface $S$ is  homeomorphic to $R^2$ (as it is either equal to ${\mathbb C}$ or is conformal to the unit disk). Lastly, use Jordan curve theorem (which one again can prove via Alexander duality) to conclude that every Jordan curve bounds a disk in $S$.
Just for fun, you may want to ask your instructor if this is the proof that he/she had in mind.
Comment: The first direction of the proof can be done by much more elementary means (though of course still far beyond Calc III); see for instance my answer at https://math.stackexchange.com/questions/1440322/finding-holes-in-a-non-simply-connected-open-subset-of-mathbbc.
Comment: Also, I believe your interpretation of the lecturer's definition isn't quite right: it's not that every Jordan curve encloses a disk, but that the entire disk which it encloses in $\mathbb{R}^2$ is contained in your space.  These are equivalent, but it is not obvious that they are.
Comment: @EricWofsey: You are right: If you have a hammer, everything looks like a nail....
Comment: @MoisheCohen I've already self-studied general topology and I'm currently self studying algebraic and differential topology, so feel free to use whatever machinery you see fit
Answer: The points "enclosed" by a simple closed curve in $\mathbb{R}^2$ are the bounded component of its complement in $\mathbb{R}^2$.  That is, if $C\subset\mathbb{R}^2$ is (the image of) a simple closed curve, $\mathbb{R}^2\setminus C$ always has two connected components (by the Jordan curve theorem), one of which is bounded.  The points "enclosed" by $C$ are the points of the bounded component.  So for instance, if $C=\mathbb{S}^1$, it encloses the entire open unit disk.  This means that according to youre lecturer's definition, a simply connected subset of $\mathbb{R}^2$ which contains $\mathbb{S}^1$ must also contain the entire unit disk.
Your lecturer's definition of "simply connected" is in fact equivalent to the standard one for connected open subsets of $\mathbb{R}^2$.  The proof is difficult.  As a sketch of a proof, any simple closed curve in $\mathbb{R}^2$ cannot be contracted to a point in the complement of any point it encloses, and so if $D$ is simply connected by the usual definition it must satisfy your lecturer's condition.  Conversely, if $D$ is not simply connected, any nontrivial loop in $D$ can be homotoped to one with only finitely many self-intersections, and thus can be broken into finitely many simple closed curves.  If all enclosed points of all these simple closed curves were in $D$ then the loop would be nullhomotopic in $D$, so $D$ cannot satisfy your lecturer's definition.


How to proactively prevent termite infestation

Question: I'm seeing ants boring holes through Tiles and ejecting sand and I'm told ants are first to come then comes the Termite.
Outside my building I'm seeing lots of ant colonies where if can lay our feet , it just starts biting.

I have 6 Sewage pits( made of concrete ring ) around my building.
As far as I understand , soil with moisture around the house is invitation for the Termites.

Please find detailed videos here ( 1 , 2 ).
What are the pro-active steps that I can take to prevent my house from become target for Dampwood / Drywood /Subterranean Termites,Swarms,Carpenter Ants and other boring insects.
FYI:
There's a termite infestation on the banks of small water irrigation canal which is 100 feet away.
Update: - When it rains , I see the flying insects making its way in and around the home.  Could it be a boring insect or some kind of flying termite ?
Comment: It's probably too late now, but avoid burying pieces of wood. Where in the world are you?
Comment: I'm from India.Can I see some plants so that it'll take the moisture away from soil.. Any ideas ?
Answer:
Dig a trench around the perimeter of house.

Buy some high quality anti termite chemicals such as Termador and mix that with less water and pour it on the trench around the house. Give it couple of weeks to get absorbed the soil below. This will kill the subterranian termites

Make sure there's no paper or cardboard box or wood around the house this will draw the damp or dry wood termites.

Keep you windows and other holes covered with mosquito net , this will prevent flying termites from entering into home.

Keep the wood items dry in your house.

Keep an eye on any mud tunnels around and in the house.If you ever spot any remove it physically first and apply or pour Termador kind of chemicals on it so the Termite colony would get destroyed

BAIT STATION is another approach to kill off any neighboring Termite colonies. Basically you will have to buy and install the bait station around the house , the cellulose in the bait station , lures the worker termites and when it feeds , it'll die off along with its colony.

My Recommendation:
-> Chemical approach first( to mark off your house from termites )
-> Bait station ( to kill off any neighbhoring Termite colonies .. imagine termites growing in a tree stump near by your house , it's just matter of time .. when the root reaches under your house foundation these Sub terranian Termites can travel and come in to your house easily.
-> Keep the items( Paper, dry/wet wood ) away from the permitter of house
-> Mosquito net


How to check for a NullPayload in mule dataweave

Question: I have a seen plenty of examples of checking for null in a mule data weave but none that check for a NullPayload.
When I try when payload[1] is NullPayload in the dataweave it complains saying missing ':' at 'NullPayload'. Adding the : results in the run time error Invalid input ":NullPayload ", expected :trait or :type.
I know I can't check for null since it's not the same as a NullPayload but I don't know the syntax to check for a NullPayload in a dataweave.
I'm using Mule runtime 3.8.5
Answer: payload is :null should work as NullPaylod is mapped to null value. Also payload == null
Answer: You can use
payload is :empty or payload is :null

Sample
    %dw 2.0
%output application/json
---
{
    response : "Payload Is blank" when (payload is :empty or payload is :null) otherwise "payloadData"
}

You can replace "payloadData" with payload as per your flow


Why doesn't $f(z) = | z |^{2}$ contradict Morera's theorem?

Question: Consider the function $f(z) = | z|^{2}$. It is continuous on some open ball $D$ around the origin, but is only complex differentiable at the origin. Therefore it is not holomorphic on $D$.
Further, $f(z)$ has no poles in $D$ so by the residue theorem the integral over any closed curve is $0$.
Why then does this not contradict Morera's theorem, which states:
If $f$ is continuous on an open disc and the integral of $f$ over all closed curves in the open disc is zero then f is holomorphic.
Comment: If you want to use the residue theorem then you need a *holomorpic function*  except for a finite set of singular points. Does $\;|z|^2\;$ fulfill this?
Answer: The residue theorem you're trying to appeal to only applies if you already know that the function is complex differentiable (except for isolated singularities). This one definitely isn't.
Answer: Try to integrate over a half circle centered at the origin of radius $1$, namely go from $1$ to $-1$ in a straight line and then around a circle of radius $1$ from $-1$ back to $1$ . The straight segment will contribute to
$$
\int_{1}^{-1} z^2 dz = \left. \frac{z^3}3 \right|_{1}^{-1} = -\frac 23
$$
and the circle arc will contribute to
$$
\int_{-1}^1 dz = \left. z \right|_{-1}^1 = 2.
$$
The point of this example is that even without computing anything (the proof that I didn't compute and still had faith is that I got the computations wrong the first time... yet it was still the correct example!), is that $|z|^2$ is a function which behaves significantly differently along radial axes compared to along centered circle arcs, so I exploited this fact to find my example. Along a circle is not a problem for this function since it behaves like a constant on these (and constants are holomorphic, so...)
Hope that helps,
Comment: Um ... I think it is _odd_ functions where $\int_{-a}^a f(x)\,dx$ vanishes, not even ones.
Comment: @HenningMakholm : Oh dear, what a fail. Maybe the example still works though, let me compute
Comment: It should still work. (But I'm not sure why you're using radius $1/2$ instead of $1$).
Comment: @HenningMakholm In my head, the disk had radius $1$. I'll edit my answer to fix things!


PageCurl(magazine) with Image from web

Question: I am working with Harism Page Curl(Open GL) https://github.com/harism/android_page_curl and its works perfectly fine

But in this example the condition I found is that we must have all Bitmap resource ready(downloaded) but what I want is image will going to load(runtime) from web and will be cache for future like this.

Want some idea that how would I achieve this? a small help/hint is also appreciated. :)
Thanks.
Comment: It will not be a good user experience to see a progress bar for images to load in a magazine kind of application. It would be better if the images could be loaded beforehand by anticipating the page turn. You could show a placeholder image for unloaded images. Please see various magazine apps and also FlipBoard
Comment: You can achieve this thing, but you have to create your own custome view , to do that. What it would do is it will draw this view on canvas and then effect the page curl on canvas instead of view. so by doing that you can put any view inside your custom view on make it curl. Hope this example will help you, cos its creating own view and making it curl.http://code.google.com/p/android-page-curl/
Comment: @Rajesh have a look on this http://app2.diariolibre.com/revistas/mujerunica/
Comment: It was just a usability comment. Technically, it is possible and I will post a suggestion to achieve it, as an answer.
Comment: there is no view that will satisfy your runtime needs..!! You will definately have to make a custom view, draw it on canvas and give it a curl effect
Comment: I had seen code.google.com/p/android-page-curl but its having issues. May be you are right that I have to deal with CustomView.
Comment: @hotveryspicy what was the solution finally that you opted.
Comment: @Rajesh Will you please help me with a similar thread, I am almost done just need an advice.
Comment: @hotveryspicy is there some sort of listener that can tell if the page has been changed?
Comment: @hotveryspicy Please see my question: http://stackoverflow.com/questions/30726077/page-curl-with-best-quality
Answer: This answer assumes that you want to use the Page Curl by Harri Smått (harism) and nothing else.
There are different ways to achieve the wait screen with progress bar:

Create a custom view that will display the image for every page. When the required image is not available, it will display the wait message together with the progress bar while downloading the image in the background.  The BitmapProvider returns the bitmap captured from this custom view (by either using a Canvas or using the drawingCache).  What is to be noted is that the CurlView will need to be updated with the latest image from the view whenever there is a change in progress. This can be done by requestRender method.
Create an OpenGL progress widget. Whenever the image is not available and need to be downloaded, this progress widget together with the message is shown in place of the page. When the download gets completed, the view is re-rendered with the downloaded image.
Comment: Where do I need to call requestRender can you help on that?
Comment: Without seeing your implementation, it is difficult to make a suggestion. If you are using an AsyncTask for the download, the ideal place would be the [onProgressUpdate](http://developer.android.com/reference/android/os/AsyncTask.html#onProgressUpdate(Progress...)) method.
Comment: Ok I will post a thread and then comment here for your reply.
Comment: http://stackoverflow.com/q/16373550/1503130 , I have created a thread of my question here, Please have a look at it.
Comment: I saw your question and there was already an accepted answer.
Comment: Yea but I want to understand the concept of how do I control this customview
Comment: Also I can award a bounty if I get the right answer to my question but with some code example.
Comment: @Rajesh Please see my question: http://stackoverflow.com/questions/30726077/page-curl-with-best-quality
Answer: One option is to do something like this How To apply click listener?, which suggests to maintain two views (one on top of another).
The first one will hold the views you need (the current page if already loaded, otherwise the ProgressBar). The second one will be the OpenGL surface view by harism, which will make the page curling. This way, you can play with hiding/showing/bringing them to top/bottom when you need it.
Comment: Can you give some sample code of tweaked harism project with progress bar functionality.
Comment: @pKs No, I'm sorry. The way I used harism library is far from the desired behaviour here.
Comment: Actualy one thing that I want is to simulate page drag on click button , how can I do this. Any clues?
Comment: @pKs  You could try creating your custom MotionEvent's and sent them to the CurlView (mCurlView.onTouch(null, event)). This way you don't need to modify the harism library.
Comment: But this doesn't curl the page, I have generated the `MotionEvent` object and am able to simulate `onTouch` but can't able to turn the page.
Comment: @pks You need to create a ton of them. The first one with the ACTION_DOWN, the following ones with ACTION_MOVE and the last one with ACTION_UP. You also have to be concerned about different screen sizes.
Comment: How can I come to know if my page has been completely curled as I have to check this condition and then execute some code in the `if block`
Comment: hey I have done the button click motion part , but I have got another problem , when I tried to curl from left to right then the indexes are not properly maintained the bitmaps are not the right ones with respect to the current indices. you must have faced this while doing a curl from left to right. Can you give me a clue on this.

PageCurl(magazine) with Image from web


Show that $G \cong D_4$.

Question:
Consider the polynomial $f(x_1,x_2,x_3,x_4) = x_1 x_2 + x_3 x_4.$ Let $G$ denote the symmetry group of $f$ consisting of those permutations of $x_1,x_2,x_3$ and $x_4$ which leave $f$ fixed. Show that $G \cong D_4$ where $D_4$ is the symmetry group of the square.

I have found the symmetry group of $f$ to be $H=\{(1),(1\ 2),(3\ 4), (1\ 2)(3\ 4), (1\ 3)(2\ 4), (1\ 4)(2\ 3), (1\ 3\ 2\ 4), (1\ 4\ 2\ 3) \}.$ I know that $D_4 \cong G$ where $G$ is a group generated by two of its elements $a$ and $b$ such that $o(a)=4$ and $o(b)=2$ along with $ba=a^3 b.$ From this stage how should I proceed? Do I take $a=(1\ 3\ 2\ 4)$ and $b=(1\ 2)$ or $(1\ 3)(2\ 4)$ here or should I go for other options?
As I am new to this subject I dont know how to conclude.Please help me.
Thank you in advance.
Answer: Since they specifically meantion squares, lets' get geometric. Draw a square and put your variables in the corners in the following pattern:
$$
\begin{matrix}
x_1&x_3\\x_4&x_2
\end{matrix}
$$
Then $f$ is the sum of the product of the two diagonals. Surely, applying a symmetry of that square preserves which variables are diagonally opposite one another. Thus $D_4$ is a subgroup of $G$.
Conversely, any permutation that preserves which elements are diametrically opposite one another is a symmetry of that square: If I make a different square using the same numbers with $x_1$ and $x_2$ diametrically opposite one another, then there is an element of $D_4$ that translates between my two squares. Thus $G\subseteq D_4$.

Show that $G \cong D_4$.


Ubuntu 9.10 screen on VirtualBox turns black?

Question: Hi guys I have win7 and I wanted to move to Ubuntu,I got a Ubuntu 9.10 desktop edition DVD and installed it on VirtualBox, but I had a problem with the screen display size. I followed the tutorial here: VirtualBox/Ubuntu 9.10: Changing Screen Resolution.
I restarted Ubuntu; it starts good, but the desktop won't show up. It turns black and nothing happens. Does anyone have an idea?
Comment: Welcome to Ask Ubuntu! New questions about [end-of-life](https://wiki.ubuntu.com/Releases#End_of_Life_.28EOL.29) Ubuntu releases are considered off-topic as per [the FAQ](http://askubuntu.com/faq). These old releases are unsupported and their use is not recommended. They don't even get updates for newly discovered security vulnerabilities, which makes using them risky. If you install or upgrade to [a supported release](https://wiki.ubuntu.com/Releases#Stable) and this question still applies, please flag and/or comment to request it be reopened.
Comment: Then please close this question :)
Comment: I think you'll find that  this question gets marked as Off Topic. Mainly because the version of Ubuntu (9.10) is not supported any more,
Answer: If you have a good internet connection, download the Ubuntu 12.04LTS for the most stable release of Ubuntu, and the currently most supported version.  You will probably enjoy it much better than 9.10.
Answer: without beeing able to exactly point out what went wrong on ur virtualbox install, i think it make sense to suggest u two relevant things:

u really should use a more actual version of ubuntu then 9.10! besides that the newer version may better support new hardware, i fear 9.10 isnt even supported with updates anymore.so i suggest u to use 12.04 which is a LTS (long time support) version.
if u wanna give ubuntu a try,u also can boot a fresh ubuntu live-system from DVD or USB and play around with it without changing anything to the actual configuration of ur machine.

and to ur question, it may a bit unprecise but i would suggest u to also try the virtualbox install with a fresher ubuntu like 12.04 + to make sure it matches ur hardware better.
have fun (-:


Why is the area under a curve the integral?

Question: I understand how derivatives work based on the definition, and the fact that my professor explained it step by step until the point where I can derive it myself.
However when it comes to the area under a curve for some reason when you break it up into an infinite amount of rectangles, magically it turns into the anti-derivative. Can someone explain why that is the definition of the integral and how Newton figured this out?
Comment: There are 2 potential questions here.  One is the question of why the definite Riemann integral gives the correct notion of "area under a curve" for a (nonnegative, Riemann integrable) function.  The other, which seems to be what you're really asking, is the question of why an antiderivative evaluated at the endpoints of an interval and subtracted yields that definite integral.  The latter question is answered by an understanding of the fundamental theorem of calculus.  The purpose of this comment is just to help clarify your question.
Comment: @qwertymk: Well, now you have a fabulous explanation from Arturo Magidin, but I'll also mention that http://en.wikipedia.org/wiki/Riemann_integral is a good starting point for learning about how the integral is actually defined, while http://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus is a good starting point for learning about the relationship with antiderivatives.  Both include excellent graphics!
Comment: @picakhu: I think that he or she is certainly seeking intuition, but the phrase "magically it turns into the anti-derivative" indicates that this is really about the fundamental theorem of calculus, and not just about the definition of the integral.
Comment: Its also possible that he is seeking the intuition for Calculus. Specifically integration
Comment: I understood the question quite clearly, because I had the same question.
Comment: @qwertymk: I've added some stuff on why the limits of the Riemann sums "should be" the area under the graph. I hope it's intelligible.
Comment: I just want to to point out something too. If you think about the derivate gives you the slope at a single point, and remember that the slope of simple line uses division, (the height divided by the width). The area under a rectangle, is the height times the width. Multiplication is of course simply the reverse of division and vice versa. Calculus is basically the same stuff, only with curves. So it basically makes sense. A derivative is sort of like the division and the integral is sort of like the multiplication. And so, the integral is opposite the derivate (or anti-derivative).
Comment: I don't understand the difference between the two
Comment: http://math.stackexchange.com/questions/925465/is-there-any-geometric-explanation-of-relationship-between-integral-and-derivati/925559#925559
Answer: First: the integral is defined to be the (net signed) area under the curve. The definition in terms of Riemann sums is precisely designed to accomplish this. The integral is a limit, a number. There is, a priori, no connection whatsoever with derivatives. (That is one of the things that makes the Fundamental Theorems of Calculus such a potentially surprising thing).
Why does the limit of the Riemann sums actually give the area under the graph? The idea of approximating a shape whose area we don't know both from "above" and from "below" with areas we do know goes all the way back to the Greeks. Archimedes gave bounds for the value of $\pi$ by figuring out areas of inscribed and circumscribed polygons in a circle, knowing that the area of the circle would be somewhere between the two; the more sides to the polygons, the closer the inner and outer polygons are to the circle, the closer the areas are to the area of the circle.
The way Riemann tried to formalize this was with the "upper" and "lower" Riemann sums: assuming the function is relatively "nice", so that on each subinterval it has a maximum and a minimum, the "lower Riemann sum" is done by taking the largest "rectangle" that will lie completely under the graph by looking at the minimum value of the function on the interval and using that as height; and the "upper Riemann sum" is done by taking the smallest rectangle for which the graph will lie completely under it (by taking the maximum value of the function as the height). Certainly, the exact area under the graph on that interval will be somewhere between the two. If we let $\underline{S}(f,P)$ be the lower sum corresponding to some fixed partition $P$ of the interval, and $\overline{S}(f,P)$ be the upper sum, we will have that
$$\underline{S}(f,P) \leq \int_a^b f(x)\,dx \leq \overline{S}(f,P).$$
(Remember that $\int_a^bf(x)\,dx$ is just the symbol we use to denote the exact (net signed) area under the graph of $f(x)$ between $a$ and $b$, whatever that quantity may be.)
Also, intuitively, the more intervals we take, the closer these two approximations (one from below and one from above) will be. This does not always work out if all we do is take "more" intervals. But one thing we can show is that if $P'$ is a refinement of $P$ (it includes all the dividing points that $P$ had, and possibly more points) then
$$\underline{S}(f,P)\leq \underline{S}(f,P')\text{ and } \overline{S}(f,P')\leq \overline{S}(f,P)$$
so at least the approximations are heading in the right direction. To see why this happens, suppose you split one of the subintervals $[t_i,t_{i+1}]$ in two, $[t_i,t']$ and $[t',t_{i+1}]$. The minimum of $f$ on $[t_i,t']$ and on $[t',t_{i+1}]$ are each greater than or equal to the minimum over the whole of $[t_i,t_{i+1}]$, but it may be that the minimum in one of the two bits is actually strictly larger than the minimum over $[t_i,t_{i+1}]$. The areas we get after the split can be no smaller, but they can be larger than the ones we had before the split. Similarly for the upper sums.
So, let's consider one particular sequence of partitions: divide the interval into 2 equal parts; then into 4; then into 8; then into 16; then into 32; and so on; then into $2^n$, etc. If $P_n$ is the partition that divides $[a,b]$ into $2^n$ equal parts, then $P_{n+1}$ is a refinement of $P_n$, and so we have:
$$\underline{S}(f,P_1) \leq\cdots \leq \underline{S}(f,P_n)\leq\cdots \leq\int_a^b f(x)\,dx \leq\cdots \leq\overline{S}(f,P_n)\leq\cdots \leq \overline{S}(f,P_2)\leq\overline{S}(f,P_1).$$
Now, the sequence of numbers $\underline{S}(f,P_1) \leq \underline{S}(f,P_2)\leq\cdots \leq \underline{S}(f,P_n)\leq\cdots$ is increasing and bounded above (by the area). So the numbers have a supremum; call it $\underline{S}$. This number is no more than $\int_a^b f(x)\,dx$. And the numbers $\overline{S}(f,P_1) \geq \overline{S}(f,P_2)\geq\cdots \geq \overline{S}(f,P_n)\geq\cdots$ are decreasing and bounded below, so they have a minimum; call this $\overline{S}$; again, it is no less than $\int_a^bf(x)\,dx$. So we have:
$$\lim_{n\to\infty}\underline{S}(f,P_n) = \underline{S} \leq \int_a^b f(x)\,dx \leq \overline{S} = \lim_{n\to\infty}\overline{S}(f,P_n).$$
What if we are lucky? What if actually we have $\underline{S}=\overline{S}$? Then it must be the case that this common value is the value of $\int_a^b f(x)\,dx$. It just doesn't have a choice! It's definitely trapped between the two, and if there is no space between them, then it's equal to them.
What Riemann proved was several things:

If $f$ is "nice enough", then you will necessarily get that $\underline{S}=\overline{S}$. In particular, continuous functions happen to be "nice enough", so it will definitely work for them (in fact, continuous functions turn out to be "very nice", not just "nice enough").

If $f$ is "nice enough", then you don't have to use the partitions we used above. You can use any sequence of partitions, so long as the "mesh size" (the size of the largest subinterval in the partition) gets smaller and smaller, and has limit of $0$ as $n\to\infty$; if it works for the partitions "divide-into-$2^n$-equal-intervals", then it works for any sequence of partitions whose mesh size goes to zero.

So, for example, we can take $P_n$ to be the partition that divides $[a,b]$ into $n$ equal parts, even though $P_{n+1}$ is not a refinement of $P_n$ in this case.

In fact, you don't have to do $\underline{S}(f,P)$ and $\overline{S}(f,P)$. For the partition $P$, just pick any rectangle that has as its height any value of the function in the subinterval (that is, pick an arbitrary $x_i^*$ in the subinterval $[t_i,t_{i+1}]$, and use $f(x_i^*)$ as the height). Call the resulting sum $S(f,P,x_1^*,\ldots,x_n^*)$. Then you have
$$\underline{S}(f,P) \leq S(f,P,x_1^*,\ldots,x_n^*)\leq \overline{S}(f,P)$$
because $\underline{S}(f,P)$ is computed using the smallest possible values of $f$ throughout, and $\overline{S}(f,P)$ is computed using the largest possible values of $f$ throughout. But since we already know, from 1 and 2 above, that $\underline{S}(f,P)$ and $\overline{S}(f,P)$ have the same limit, then the sums $S(f,P,x_1^*,\ldots,x_n^*)$ also get squeezed and must have that same limit, which equals the integral.

In particular, we can always take the left endpoint (and get a "Left Hand Sum") or we can always take the right endpoint (and get a "Right Hand Sum"), and you will nevertheless get the same limit.
So in summary, you can pick any sequence of partitions, whichever happens to be convenient, so long as the mesh size goes to $0$, and you can pick any points on the subintervals (say, ones which make the calculations simpler) at each stage, and so long as the function is "nice enough" (for example, if it is continuous), everything will work out and the limit will be the number which must be the value of the area (because it was trapped between the lower and upper sums, and they both got squeezed together trapping the limit and the integral both between them).
Now, (1) and (2) above are the hardest part of what Riemann did. Don't be surprised if it sounds a bit magical at this point. But I hope that you agree that if the lower and upper sums for the special partitions have the same limits then that limit must be the area that lies under the graph.
Thanks to that work of Riemann, then (at least for continuous functions) we can define $\int_a^b f(x)\,dx$ to be the limit of, say, the left hand sums of the partitions we get by dividing $[a,b]$ into $n$ equal parts, because these partitions have mesh size going to $0$, we can pick any points we like (say, the left end points), and we know the limit is going to be that common value of $\underline{S}$ and $\overline{S}$, which has to be the area. So that, under this definition, $\int_a^b f(x)\,dx$ really is the net signed area under the graph of $f(x)$. It just doesn't have a choice but to be that, when $f$ is "nice enough".

Second, the area does not turn into "the" antiderivative. What happens is that it turns out (perhaps somewhat magically) that the area can be computed using an antiderivative. I'll go into some more details below.
As to how Newton figured this out, his teacher, Isaac Barrow, was the one who discovered there was a connection between derivatives and tangents; some of the basic ideas were his. They came from studying some simple functions and some simple formulas for tangents he had discovered.
For example, the tangents to the parabola $y=x^2$ were interesting (there was generally geometric interest in tangents and in "squaring" regions, also known as finding the "quadrature" of a region, that is, finding a way to construct a square or rectangle that had the same area as the region you were considering), and led to associating the parabola $y=x^2$ to lines of the form $y=2x$. It does not take too much experimentation to realize that if you look at the area under $y=2x$ from 0 to a, you end up with $a^2$, establishing a connection. Barrow did this with arguments with infinitesimals (which were a bit fuzzy and not set on entirely correct  and solid logical foundation until well into the 20th century), which were generally laborious, and only for some curves. When Newton extended Barrow's methods to more general curves and tangents, he also extended the discovery of the connection with areas, and was able to prove what is essentially the Fundamental Theorem of Calculus.
Now, here is one way to approach the connection. We want to figure out the value of, say,
$$\int_0^a f(x)\,dx$$
for some $a$. This can be done using limits and Riemann sums (Newton and Leibniz had similar methods, though not set up quite as precisely as Riemann sums are). But here is an absolutely crazy suggestion: suppose you can find a "master function" $\mathcal{M}$, which, when given any point $b$ between $0$ and $a$, will give you the value of $\int_0^b f(x)\,dx$. If you have such a master function, then you can use it to find the value of the integral you want just by taking $\mathcal{M}(a)$!
In fact, this is the approach Barrow had taken: his great insight was that instead of trying to find the quadrature a particular area, he was trying to solve the problem of squaring several different (but related) areas at the same time. So he was looking for, for instance, a "master function" for the region was like a triangle except that the top was a parabola instead of a line (like the area from $0$ to $a$ under $y=x^2$), and so on.
On its face, this is a completely ludicrous suggestion. It's like telling someone who is trying to know how to get from building A to building B that if he only memorizes the map for the entire city first, then he can use that knowledge to figure out how to get form A to B. If we are having trouble finding the integral $\int_0^a f(x)\,dx$, then the "master function" seems to require us to find not just that area, but also all areas in between! It's like telling someone who is having trouble walking that he should just run very slowly when he wants to walk.
But, again, the interesting thing is that even though we may not be able to say what the "master function" is, we can say how it changes as b changes (remember, $\mathcal{M}(b) = \int_0^b f(x)\,dx$ is a number that depends on $b$, so $\mathcal{M}$ is a function of $b$). Because figuring out how functions change is easier than computing their values (just think about derivatives, and how we can easily figure out the rate of change of $\sin(x)$, but we have a hard time actually computing specific values of $\sin(x)$ that are not among some very simple ones). (This is also something Barrow already knew, as did Newton).
For "nice functions" (if $f$ is continuous on an interval that contains $0$ and $a$), we can do it using limits and some theorems about "nice" functions:
Using limits, we have:
\begin{align}
\lim_{h\to 0}\frac{\mathcal{M}(b+h)-\mathcal{M}}{h} &= \lim_{h\to 0} \frac{1}{h}\left(\int_0^{b+h}f(x)\,dx - \int_0^bf(x)\,dx\right)\\\
&= \lim_{h\to 0}\frac{1}{h}\int_b^{b+h}f(x)\,dx.
\end{align}
Since we are assuming that $f$ is continuous on $[0,a]$, it is continuous on the interval with endpoints $b$ and $b+h$ (I say it this way because $h$ could be negative). So it has a maximum and a minimum (continuous function on a finite closed interval). Say the maximum is $M(h)$ and the minimum is $m(h)$. Then $m(h) \leq f(x) \leq M(h)$ for all $x$ in the interval, so we know, since the integral is the area, that
$$hm(h) \leq \int_b^{b+h}f(x)\,dx \leq hM(h)\text{ if }h\gt 0,$$
and
$$hM(h)\leq\int_{b}^{b+h}f(x)\,dx \leq hm(h)\text{ if }h\lt 0.$$
That means that
$$m(h) \leq \frac{1}{h}\int_b^{b+h}f(x)\,dx \leq M(h)$$
regardless of the sign of $h$.
As $h\to 0$, the interval gets smaller, the difference between the minimum and maximum value gets smaller. One can prove that both $M$ and $m$ are continuous functions, and that $m(h)\to f(b)$ as $h\to 0$, and likewise that $M(h)\to f(b)$ as $h\to 0$. So we can use the Squeeze Theorem to conclude that since the limit of $\frac{1}{h}\int_b^{b+h}f(x)\,dx$ is squeezed between two functions that both have the same limit as $h\to 0$, then $\frac{1}{h}\int_b^{b+h}f(x)\,dx$ also has a limit as $h\to 0$ and is in fact that same quantity, namely $f(b)$. That is
$$\frac{d}{db}\mathcal{M}(b) = \lim_{h\to 0}\frac{\mathcal{M}(b+h)-\mathcal{M}(b)}{h} = \lim_{h\to 0}\frac{1}{h}\int_{b}^{b+h}f(x)\,dx = f(b).$$
That is: when $f$ is continuous, the "Master function" for areas turns out to have a rate of change equal to $f$. This is not that crazy, if you think about it: how is the area under $y=f(x)$ from $x=0$ to $x=b$ changing? Well, it's changing by whatever $f$ is.
This means that, whatever the "Master function" turns out to be, it will be an antiderivative of $f(x)$.
We also know, because we are very good with derivatives, that if $\mathcal{F}(x)$ and $\mathcal{G}(x)$ are two functions, and $\mathcal{F}'(x) = \mathcal{G}'(x)$ for all $x$, then $\mathcal{F}$ and $\mathcal{G}$ differ by a constant: there exists a constant $k$ such that $\mathcal{F}(x) = \mathcal{G}(x)+k$ for all $x$.
So, we know that the "Master function" is an antiderivative. If, by some sheer stroke of luck, we happen to find any antiderivative $F(x)$ for $f(x)$, then we know that the only possible difference between $\mathcal{M}(b)$ and $F(b)$ is a constant. What constant? Well, luckily we know one value of $\mathcal{M}(b)$: we know that $\mathcal{M}(0) = \int_0^0f(x)\,dx$ should be $0$.  So, $M(0) = 0 = F(0)-F(0)$, which means the constant has to be $-F(0)$. That is, we must have $M(b) = F(b)-F(0)$ for all $b$.
So, if we find any antiderivative $F$ of $f$, then $\mathcal{M}(b) = F(b)-F(0)$ is in fact the "Master function" we were looking for, the one that gives all the integrals between $0$ and $a$, including $0$ and including $a$. So that we have that two very different processes (computing areas using limits of Riemann sums, and derivatives) are connected: if $f(x)$ is continuous, and $F(x)$ is any antiderivative for $f(x)$ on $[0,a]$, then
$$\int_0^a f(x)\,dx = \mathcal{M}(a) = F(a)-F(0).$$
But the integral did not "magically turn" into an antiderivative. It's that the "Master function" which can be used to keep track of all integrals of $f(x)$ has rate of change equal to $f$, which gives us a "back door" to computing integrals.
Newton was able to prove this because he had the guide of Barrow's insight that this was happening for the functions he worked with. Barrow's insight was achieved because he had the brilliant idea of trying to come up with a "Master function" instead of trying to rectify lots of different areas one at a time, and he noticed the connection because he had already worked with tangents/derivatives for those functions. Leibniz likewise had access to Barrow's ideas, so the connection between the two was also known to him.
Comment: It was intended to be a (horrible) pun, but sure, I won't do it again. ;)
Comment: Just a tiny note: "finding a way to construct a rectangle that had the same area as the region you were considering" would be what they called in those days "quadrature". Otherwise, this answer is a work of Art, as expected. :)
Comment: @J.M.: Oh, I got the pun all right (hence the winking smiley, and I did see your smiley). Just wanted to nip any possibility of the nickname getting picked up in the bud.
Comment: @J.M. That's what I get for not checking the proper term in English and trying to go by with dim recollections of what it was in Spanish... Thanks. (And don't call me "Art"; I don't care for it (-; ).
Comment: Where can I find Riemann's proof that the area under the curve of a continuous function is given by the definite integral?
Comment: @ArturoMagidin Why it is $$\underline{S}(f,P) \leq \int_a^b f(x)\,dx \leq \overline{S}(f,P).$$ and not $$\underline{S}(f,P) < \int_a^b f(x)\,dx < \overline{S}(f,P)$$ ?
Comment: @user599310: You can get lucky and get it equal; sometimes they *will* be equal; for example, if $f$ is contant.
Comment: @ArturoMagidin But how from $$\underline{S}(f,P) < \int_a^b f(x)\,dx < \overline{S}(f,P)$$ we can conclude that limit of Riemann sum gives the exact area? Is beacuse the limit at infinity are equal therefore the area can't be larger or smaller than the limit. So the only possibility is that they are equal? Do you have any source for the formal proof that the limit at infinity equals the area? Thanks in advance.
Comment: @user599310: Again, we don't have strict inequalities. Again, **as is stated in the answer**, this is not enough; you need the function to have other properties (for example, continuity). Any decent book in real analysis will contain a proof. Just look.
Comment: @ArturoMagidin I will check it out. Damn, that Calculus courses for Chemists don't care about proofs.
Answer: One way you can perhaps "justify"/give an intuitive reason is to consider the following figure:

$A(x)$ is the area under the curve from $0$ to $x$, the brown region.
$A(x+dx)$ is the area under the curve from $0$ to $x + dx$, the brown + gray.
Now for for really small $dx$, we can consider the gray region to be a rectangle of side width $dx$ and height $f(x)$.
Thus $\dfrac{A(x+dx) - A(x)}{dx} = f(x)$.
Thus as $dx \to 0$, we see that $A'(x) = f(x)$.
It is kind of intuitive to define area by approximating by very thin rectangles. The above gives an intuition as to why the derivative of the area gives the curve.
Comment: how does this make F(x) = A(x)
Comment: @MuhammadUmer: Because of fundamental theorem of calculus. See this:http://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus#Second_part (and I suggest you read the whole page).
Comment: thanks, i've read. Why does the proof of 1st part, `For a given f(t), define the function F(x) as..`, start with assumption that F(x) or integral = area..because that is what it's made equivalent to when mean value theorem is used which is area.
Comment: @MuhammadUmer: I don't understand what you are trying to say. The second part applies here.
Comment: I see why $A'(x) = f(x)$ when $dx \to 0$, but, for $dx\in \mathbb R$, should't it be $\frac{A(x+dx)-A(x)}{dx} = f(c)$, where c is defined by the mean value theorem?
Comment: @user258607: It is assumed to be a rectangle and the answer is only to provide some intuition. But I suppose a proof can be given the way you suggest.
Answer: I strongly recommend that you take a look at the first chapter of Gilbert Strang's Calculus textbook: http://ocw.mit.edu/resources/res-18-001-calculus-online-textbook-spring-2005/textbook/MITRES_18_001_strang_1.pdf. This chapter provides an insightful introduction to integration that likely takes an approach that is very different from your professor's.
A typical explanation of integration is as follows:

We want to know the area under a curve. We can approximate the area under a curve by summing the area of lots of rectangles, as shown above. It is clear that with hundereds or thousands of rectangles, the sum of the area of each rectangle is very nearly the area under the curve. In the limit, we get that the sum is exactly equal to the area. This animation may help with the intuition,

We define the integral to be the limit described and depicted above:
$\int _{ a }^{ b }{ f(x)dx=\lim _{ n\rightarrow \infty  }{ \sum _{ i=1 }^{ n }{ f({ x }_{ i })\Delta x }  }  } $
Comment: Question is asking about why of what you showed and stopped there with last part. Somehow infinite triangles equals the difference in antiderivatives???
Answer: I remember thinking about this problem in high school.  Here is the intuitive explanation that popped into my head one morning before I got out of bed.  I am assuming the question you are asking is why the antiderivative evaluated at the endpoints gives you the area under the curve.
Let $f(x)$ be a function on an interval $[a,b]$.  We want to calculate $\int_a^b f(x)dx$, i.e. the area under the curve of $f$ from $a$ to $b$.  Intuitively, $\int_a^b f(x)dx$ is the infinite sum of all rectangles with height $f(x)$ and width $dx$, and we are summing over all $x$ in the interval $[a,b]$. Let's take for granted that this expression $\int_a^b f(x)dx$ really is referring to the area under the curve.
Let $y = F(x)$ be an antiderivative of $f$.  So $\frac{dy}{dx} = f$.
Choose any finite sequence of points $a = x_0 \leq \cdots \leq x_t =b$.  We have the 'net change' $F(b) - F(a)$, and on the other hand we have the 'small changes' $F(x_1) - F(a), F(x_2) - F(x_1)$ etc.  But if you add all the small changes:
$$[F(x_1) - F(a)] + [F(x_2) - F(x_1)] + \cdots + [F(b) - F(x_{t-1})]$$ you get the net change, $F(b) - F(a)$.  The sum of the small changes is the net change.  Now imagine infinitely many points there.  Each small change, which I might have written as $\Delta y$, is now written as $dy$ (this is the notational tradition in calculus).  And again, the net change is the (now infinite) sum of the (infinitely small) small changes: $$F(b) - F(a) = \int_a^b dy$$ But $$\int_a^b dy = \int_a^b \frac{dy}{dx}dx = \int_a^b f(x)dx$$
Comment: There are of course many logical difficulties with this explanation, in particular the problem of summing up infinitely (uncountably many) terms, as well as the general problem of declaring "since this works for finitely many things, it must also be true for infinitely many things."  If you study real analysis, you will learn what is "really" going on.
Comment: But I still think this is a good intuitive way to think about what the fundamental theorem of calculus is saying.  When I think FTOC, I think "The net change is the sum of the small changes."
Answer: If $y=f(x)$, then from following geometric figure we can conclude that no mater where our reference point (the point from where area is measured) is, $y$ approximately equals $\dfrac{\Delta A}{\Delta x}$.

Therefore no matter where our reference point is:
$$y=\lim_{{\Delta x}\to\ 0}\dfrac{\Delta A}{\Delta x}=\dfrac{dA}{dx}$$
Therefore from the fundamental theorem of calculus, we can conclude that no matter where our reference point is:
\begin{equation}
A=\int y\ dx
\tag{1}
\end{equation}
Equation (1) says $A$ contains an undefined constant. That is, $A$ are infinite functions of $x$ all differing by constants.
Now if we take undefined constant as zero, then at reference point $x=a$, let us say $\int y\ dx=k$.

From this, the value of $\text{area} =A=\int y\ dx$ [between reference point $x=a$ and point $x=\alpha$] can be found.That is:
\begin{equation}
\left[ \text{area} \right]^{\alpha}_{a}
=\left[ A \right]^{\alpha}_{a}
=\int^{\alpha}_{a} y\ dx
=\left[ \int y\ dx  \right]_ {\text{at}\ \alpha}  -\ k
\tag{2}
\end{equation}
Similarly, the value of $\text{area} =A=\int y\ dx$ [between reference point $a$ and another point $x=\beta$] can be found. That is:
\begin{equation}
\left[ \text{area} \right]^{\beta}_{a}
=\left[ A \right] ^{\beta}_{a}
=\int^{\beta}_{a} y\ dx=\left[ \int y\ dx  \right]_ {\text{at}\ \beta}  -\ k
\tag{3}
\end{equation}
Substracting $(2)$ from $(3)$:
$$\left[ \text{area} \right]^{\beta}_{\alpha}
=\left[ \text{area} \right]^{\beta}_{x_1}-\left[ \text{area} \right]^{\alpha}_{x_1}
=\left[ \int y\ dx  \right]_ {\text{at}\ \beta}-\left[ \int y\ dx  \right]_ {\text{at}\ \alpha}
=\int^{\beta}_{\alpha} y\ dx$$
Answer: heres a very simple explanation of how an integral works. Forget about things needed for the proof. This is just for the concept
take the function f'(x) and its antidervative, f(x)
We can find the area under a graph by taking the average of all the y values and multiplying by  Delta X, creating a rectangle of equal area.
<code> (1)Area = Yaverage of f'(x)* DeltaX
  average y for f'(x) is average slope of f(x)
</code>
finding average slope of f(x) is easy. Simply go to the original function and do the average slope calculation
<code> (2)average slope =(y1-y2)/(deltaX)
</code>
Now substitute formula 2 into 1:
<code>  area of f'(x) = (y1-y2)/delaX  * deltaX
  area of f'(x) = (y1-y2)
</code>
y1 = f(x1)
<code> area of f'(x)=f(x1)-f(x2)
</code>
Took me a while to figure this out. IMO the mean sum of tiny squares hinders understanding. mean value theorem is good to find average slope. Its convoluted and imprecise though when people say there is a value c that does this or that. Irrelevant to finding the average slope. Just supply the formula for finding average slope. Best of luck
Such a simple concept to be so over complicated. I hope they change the way it is taught in canadian schools


Bouncy Castle : PEMReader => PEMParser


Change text align of div from dropdown selection?

Question: I have a few dropdown list to style the font of a div. However i cant seem to get the align to work. Please help!!
I have always found my answers on google and not had such a tough time getting round things. The align is really bugging me, that i cant find a solution.

And the body is aa such:

Size:
    <select name=fontSizeChanger onchange="fontSize(this.value)">
        <option value="6">6</option>
         <option value="8">8</option>
         <option value="10">10</option>
         <option value="12" selected="selected">12</option>
         <option value="14">14</option>
         <option value="16">16</option>
         <option value="18">18</option>
         <option value="20">20</option>
    </select>

    Colour:
    <select id="color" onclick="setColor();">
        <option value="white">white</option>
        <optionvalue="black"selected="selected">black</option>
        <option value="red">red</option>
        <option value="lightblue">light blue</option>
        <option value="darkblue">dark blue</option>
        <option value="lightgreen">light green</option>
        <option value="darkgreen">dark green</option>
        <option value="yellow">yellow</option>
        <option value="orange">orange</option>
        <option value="pink">pink</option>
        <option value="purple">purple</option>
        <option value="gray">gray</option>
    </select>

    Family:
    <select id="fontFamilyChanger" onchange="fontFamily(this.value)">
<option value="sans-serif" selected="selected">Sans Serif</option>
        <option value="Impact">Impact</option>
    <option value="times new roman">Times New Roman</option>
    </select>

    Style:
    <select id="fontStyleChanger" onchange="fontStyle(this.value)">
    <option value="normal" selected="selected">Normal</option>
        <option value="italic">Italic</option>
        <option value="oblique">Oblique</option>
    </select>

    Weight:
    <select id="fontWeightChanger" onchange="fontWeight(this.value)">
    <option value="normal" selected="selected">Normal</option>
    <option value="bold">Bold</option>
    </select>

    Align:
    <select id='s' name='s'  onchange="alignl(this.value);">
        <option value="left">left</option>
        <option value="right">right</option>
        <option value="center">center</option>
        <option value="top">top</option>
    </select>

    <form name="myForm">
        <input name="myContent"></input>
        <input type="button" value="Add content" onClick="addContent('lineOne', document.myForm.myContent.value); setCookie('content', document.myForm.myContent.value, 7);">
    </form>

Answer: You can set the align in the same way you set the other styling properties, but the variable is named textAlign, not align.
function alignl(style)   {
  document.getElementById("lineOne").style.textAlign = style;
}

Comment: Thank you very much. The simplest answers are always the hardest to solve. In my case anyways.
Comment: I want to add more input boxes to the list and have it styled seperately. How will this be done. I need different lines of text in a div styled the differently from the previous line.


Panel not theming

Question: I'm running ubuntu 15.10 and my panel doesn't change theme anymore. It remains the default theme. In addition to this I my icons will no longer change icon pack, and remain the default. This is quite frustrating and I cannot fix it.
I would appreciate any help
Answer: To solve this just type:
ALT + F2 then type unity --reload
Alternatively you can do this through the terminal, but be sure to leave the window open for a while, as otherwise it will fail to load all UI elements.

Panel not theming