Extremely slow computer (Dell Optiplex 270)

Question: I need help identifying what is making my spare computer so slow.  It is an old Dell Optiplex 270 that used to work in Windows but I am trying to bring back to life for my wife to use.  Unfortunately it is so slow that one cannot type more than a couple of characters per second!  This means it is essentially useless.  The boot is not too slow but logging in is and then working with it is painful.  This was not the case when the Windows drive was installed.
These are the system specifications: Pentium 4 at 3 GHz [32 bit], 2 GB RAM, 250 GB SSD [newly installed, Toshiba THNSN256GBST], nVidia P118 FX 5200 w/ 128 MB, Rosewill Wireless NIC (no physical connection possible in that part of the house).  According to this it beats the minimum requirement by a landslide except for the graphics as it seems 256 MB is recommended.
After I upgraded the basic configuration (replaced hard drive and installed the wireless NIC), I installed 16.04 (Partition in SSD: 2 GB Swap, 80 GB for root and 174 GB  for home).  During the installation process the computer seems to behave reasonably well but upon booting from hard drive it all went down the hill.
After experiencing such slow performance I started thinking it may be the graphics card (nVidia P118, FX 5200).  I then proceeded to take out the graphics card and only use the on-board graphics.  There was no significant change in performance.  I installed the graphics card again and looked for nVidia drivers to install.  A pain and never was able to install legacy drivers properly.  Currently shows it is using Gallium 0.4 on llvmpipe (LLVM 3.8, 128 bits).
I then decided to start from scratch again but this time with 14.04 thinking this would help installing legacy drivers.  Again did not succeed and the system was just as slow.  Did not try with anything older than 14.04 as then I would have an obsolete OS.
The question is, what sort of log files are needed to help figure what is going on.  Of course, once I have those log files I will need help deciphering the information within.
Comment: I don't know what log files you need, but I would recommend installing `sudo apt-get install xubuntu-desktop` **or** `sudo apt-get install lubuntu-desktop` because it needs less resources. You can of course install Xubuntu or Lubuntu from an installation medium.
Comment: The GPU is definitely the bottleneck here. It just can't handle Unity's 3D graphics. As others have suggested, either install a lightweight DE like LXDE, or just install Lubuntu.
Comment: Regarding NVIDIA drivers - have you tried installing the driver from the NVIDIA page or the driver offered from Ubuntu's 'additional drivers' dialog?
Comment: Lubuntu is probably preferable given the limited resources. The Nvidia card will have to work with the default open-source drivers. Consider replacing the card with a newer one that can use newer drivers. The improvement will be impressive.
Comment: @dufte No, the OPS's card is legacy and the latest driver it can handle is 177. You can't install that with modern kernels, no matter where you get it from.
Comment: The graphics are certainly a problem - the llvmpipe indicates that the CPU is being used to render all of the 3d effects of the desktop, which soaks up CPU cycles...  You could perhaps use the [OIBAF drivers](https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers) but aside from that, xubuntu or lubuntu may be better choices
Comment: Black Friday is coming. Buy your loving wife a new laptop! ;)
Comment: Thank you all for your comments.  I will try what is being suggested (xubuntu or lubuntu) and report back.  I may also buy a $70 graphics card to see if this works as you all seem to agree on my suspicions (that graphics may be the issue).  If nothing works, I may have to try what WinEunuuchs2Unix suggests ;)
Comment: @JuanAntonio It's not worth throwing a $70 GPU in a system this old. Heck, you can purchase refurb systems twice as powerful for either the $70 that you would purchase the GPU for or the $90 you paid for the SSD.
Comment: Not in the small town in Atlantic Canada where I live.  BTW the $70 referred to above are $70 Canadian dollars [which is probably about 2 cents US :) ].
Answer: Thank you for the comments and suggestions.  I have now installed Lubuntu (did so from scratch) and the computer is now quite usable.  Indeed, the hardware is very old but I am impressed that I am able to work with the latest version of Ubuntu and make it a decently running computer.
On the other hand, I had never worked with Lubuntu and, after being an Ubuntu user (exclusively) for over 10 years now, I feel I am going backwards in time as the user interface is lacking so much of Ubuntu's usability. Mainstream Ubuntu developers have done a tremendous job and I guess I have grown to take things for granted.  As for Lubuntu, it will just take a bit to get used to, it comforts me to know that under the hood it is still the same great OS.


error: Placeholder matching query does not exist

Question: i'm working on a project using Django CMS. Right now im getting the following error while trying to visit my page:
 Exception Type: DoesNotExist
 Exception Value: Placeholder matching query does not exist.

It gives the error at the following line:

{% show_placeholder "practical-info" "snippets" %}

Im not quite sure what to do next. I've used a sqldumb to get all the data in the database, used
manage.py syncdb

and
manage.py migrate

to set everything up, and did it without any errors.
Hopefully someone could give me some insight in this problem! Since i don't even know what causes it exactly, it's hard for me to find a solution to it!
thx in advance!
Answer: I believe you are getting this error because the cms is expecting a page with the name "snippets" that contains a placeholder called "practical-info".  This is likely something that you'll have to create in the admin (or load via a fixture).
If this was a working site before, likely there is a cms template with the "practical-info" placeholder on it.  Create a new Page using the cms template containing that placeholder and then, under the "Advanced Settings" formset on the Page detail admin, set "snippets" to the value of id.


Tilt window does not close properly

Question: Noise and cold are coming in from the street. Any idea how I could fix this? I was thinking of attaching something to the top to push the window to the frame, but not really sure what I could use for that.
The window has a closing mechanism on the top
Comment: I don't understand how the system works. That lack of understanding severely limits the breadth of solutions I can offer.
Comment: I'm quite new to this but to me, it looks like the top locking mechanism locks into the middle of the frame. When I push the white part down it releases the frame and the window can be opened
Comment: is it your home, can you drill holes
Comment: Is there a handcrank that opens the window? Is there a release that allows the window to freely rotate down to an open position?  Is that little plastic/aluminum affordance at the top a latch release?
Comment: @popham the window can't be opened. It's tilt only. The second picture shows the open state.
Yes, it's a top latch release

asinine, Yes, the home is mine. I can drill holes.
Answer: Replace the weatherstripping, or add some more.  It looks like your black pile (fuzzy) weatherstripping isn't working right.  You may need thicker, or just add some to the inside flange of the window panel.
Comment: I'll give it a try. Thanks for the tip. I did not think of replacing the weatherstripping

Tilt window does not close properly


How to put the row count of query into a variable before I return that query in ref_cursor?

Question: I'm building a query to be used in pagination, so my query looks like this:
open ref_cursor for
select * from TableA ta
join TableB tb on ta.id = tb.ta_id
where ta.conditionA = "searchParameter1"
where tb.conditionB = "searchParameter2"
order by ta.columnF
offset i_row_offset rows
fetch next i_row_fetch rows only

I would like to return this part as output parameter, before I offset/fetch the query results:
// I would like to get the row count of this part...
o_all_row_count := select count(*) from TableA ta
                    join TableB tb on ta.id = tb.ta_id
                    where ta.conditionA = "searchParameter1"
                    where tb.conditionB = "searchParameter2"

// And then slice if by offset/fetch only the rows that I want
select * from TableA ta
join TableB tb on ta.id = tb.ta_id
where ta.conditionA = "searchParameter1"
where tb.conditionB = "searchParameter2"
order by ta.columnF
offset i_row_offset rows
fetch next i_row_fetch rows only

I can definitely do this, but this looks like I'm gonna execute twice the same searching query. How do I do this better?
Answer: I don't think you can; in order to find out how many rows are there in a cursor, you have to fetch from it and yes - that's doing the same job twice.
Answer: You can get what you want, just not directly nor easily. What you need is to expand the cursor by a column. You then populate that column with the analytic version of count building a single partition:
select ...
     , count(*) over() "rows in cursor"
  from tablea  a
  join tableb  b
    on ( ... )
 where ...;

This will in all likelihood also require you to actually specify your columns in the select (i.e. no select * ) and the subsequent fetch. See full example here.
Since I only use upper case to draw attention you can basically ignore everything except the upper case variables and the generated column in the open cursor select.
The question becomes: Is it worth the effort?

BTW your query
select * from TableA ta
join TableB tb on ta.id = tb.ta_id
where ta.conditionA = "searchParameter1"
where tb.conditionB = "searchParameter2"

is invalid. First off you can only have at most 1 WHERE clause per SELECT. Secondly, double quoting causes the value quoted to be interpreted as a variable name NOT a string constant. For value you need a single quote. The above should be:
select *
from TableA ta
join TableB tb on ta.id = tb.ta_id
where ta.conditionA = 'searchParameter1'
  and tb.conditionB = 'searchParameter2'
...


selecting 2 levels of information in one screen using search

Question: I have to levels of information, for familiarity, let's name them hospitals and doctors.
The user first searches for hospitals and somehow selects a list of them, and then for each hospital she searches for a subset of doctors who work at that hospital, and select them. So in the end of the action, I should receive a list of doctors and which hospitals they work at.
Constraints:

Has to be an intuitive design
Space is limited as this is just one step in a multi-page form
Has to be on one page only, (e.g. a wizard, multi-tabs, etc are not accepted solutions)
Number of hospitals and doctors can be very high, and hence the use of search

What have I tried:

a search textbox (for hospital search), positioned at the top of a list, when search is performed the list changes its content (i.e. hospital names that match the search will appear), each hospital name in the list has a checkbox next to it, when checked the hospital name moves to another list. when the user is done adding they can click on each hospital name in the 2nd list, and then in a 3rd list they can search for doctors and check the checkbox next to them.

Problems with this design:
sparse, too many steps, not possible for the user to see all that they selected at once, they have to click on the hospital name in the 2nd box to see what doctors they selected in the 3rd box, so i am not happy with it.
Ideally, I would want to do it in a wizard style where you first pick hospitals and then for each hospital a new wizard page appears and it you select what doctors you want, but the requirement is out of my control, and I reach a dead end here.
How would you go about it?
Comment: Do the searchers know all hospital/doctor names, or do they need to be able to browse a list of all hospitals/doctors?
Comment: @unor they should know the hopsitals and doctors they need to select before hand
Answer: why use checkbox? it sounds silly..
I'd recommend having two lists (or combo boxes, if no of hospitals and doctors < 60), what are selectable. if you select one in hospital, the doctors list will update.
They can be both vertically and horizontally aligned. whatever fits better. Its a good idea to group them with a border, so the user knows they belong together.

So the key is making the use of the filter optional. (If you click on a list, and press 'n' it should jump to that section. ) This way you can finish it by 2 clicks. However, if you want to filter the list, here it is (you can create a filter to the doctors field as well. also a better design helps):
Answer: How about something like this? Narrow the search by location. Maybe if the list gets too large reserve the first couple of columns for selected items and paginate the rest.
Answer: Because the users know the names of hospitals and doctors when they fill in your form, I'd go with the following design:
[input:hospital] → [input:doctor]
[button:add another hospital doctor]

The two input fields have autocomplete.

In the beginning, the doctor input and the button are deactivated, so users can only fill in the hospital.
When users select an autocompleted hospital name, the hospital field is deactivated and the doctor field becomes active.
When users select an autocompleted doctor name, the button becomes active (so that they can add another hospital/doctor combo)

Only if the doctor field is emptied, the hospital field becomes active again, so that the hospital name can be changed.
It would be possible to deactivate the doctor field too, as soon as the doctor name is selected. Then you should display an little "Edit" button next to the doctor field. You could also provide a "Delete" button, if necessary.
It would also be a good idea to style the input fields differently (green, or with checkmark etc.) as soon as a correct value is selected/entered, so that it's visible if a name is not known/correct (if users enter it by hand, without using the autocomplete).
If users typically add several doctors from the same hospital, you could auto-fill the next combo with the same hospital name. So users would only have to enter the doctor name, and only when they want to add doctors from a different hospital, they'd have to empty the pre-filled hospital field.

So if users filled in several hospital/doctor combos, the form would look like:
[input:hospital] → [input:doctor]
[input:hospital] → [input:doctor]
[input:hospital] → [input:doctor]
[input:hospital] → [input:doctor]
[input:hospital] → [input:doctor]

[button:add another hospital doctor]

resp. with edit/delete function:
[input:hospital] → [input:doctor] ✎ ✖
[input:hospital] → [input:doctor] ✎ ✖
[input:hospital] → [input:doctor] ✎ ✖
[input:hospital] → [input:doctor] ✎ ✖
[input:hospital] → [input:doctor] ✎ ✖

[button:add another hospital doctor]


Wrong position of elements when used with display-block

Question: I have the following HTML/CSS documents:
HTML:

    a

    a

CSS:
.test {
    border: 2px solid;
    font-size: 0;
}

.test > * {
    text-align: center;
    font-size: 20px;
    border: 1px solid;
    height: 40px;
    width: 50px;
    display: inline-block;
}

All 3 children are displayed as "inline-block". If all children have content everything is OK.
But if any of those 3 children have no content, then vertical alignment is totally wrong.
Look at this http://jsfiddle.net/ClementVidal/mb7wzy30/5/
Does any body know why this happen and for which reason ?
Note: I'm using Chrome 40.
Comment: Looks good to me, they align to baseline which is the default
Answer:
10.8 Line height calculations: the 'line-height' and 'vertical-align' properties
The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge.

Therefore you need to change the vertical-align property of the inline-block elements.
As stated above, the default value for the vertical-align property is baseline. When the sibling elements contain text, they are aligned to the baseline. By changing the vertical-align property value to something like top, the text will no longer be aligned to the base of the middle element.
Updated Example
.test > * {
    border: 1px solid;
    height: 40px;
    width: 50px;
    display: inline-block;
    vertical-align: top;
}

Answer: You can always set the vertical alignment manually:
vertical-align: middle;


Max Deck Load PSF for Hot Tub

Question: I am looking to place a 7'-10" x 9'-2" hot tub on my deck and am trying to evaluate the load capacity of the deck.
Inspecting underneath the deck it looks like the load will be evenly situated between 4 4x6 posts that are holding up dual 2x12's (There are more in each projection), and the floor is framed with 2x10's 12" on center.
The 4x6's are 8' apart one way and 5' the other.

I realize this isn't scientific and was looking for a rough guesstimate, thanks!
Answer: You don't give all the required information, but I'll make some assumptions and you tell me where I'm wrong.
I'm going to assume the water is 3' deep. Water weighs about 62 lbs. per cubic foot so the water in the tub will weigh a total of:
7'-10" x 9'-2" x (62 x 3' deep) = 13,400#
I did not add weight for equipment because I assume there are cutouts for seats, which would reduce the amount of water (weight).
In addition, I did not add weight for occupants, because that is considered an impact load (load that is not on the structure for 7 days). This weight is calculated differently.
Assuming the hot tub sits across the 2x10's in the 7'-10"direction, the 2x10's at 12" on center spanning 7' can support about 450 lbs. per foot depending on the species and grade of wood. The water and tub weighs about 3' x 62 = 186 lbs. per foot. Adding 4 people each weighing about 200 lbs. each adds another 12 lbs. per square foot. Therefore, the total weight is:
Water = 186 psf (water 3' deep) plus
Lumber = 8 psf (deck and joists) plus
People = 12 psf  (4 people in tub) for a
Total = 206 psf (well within a safety factor)
However, in addition to supporting the tub, the double 2x12's need to support a live load adjacent to the tub too. Therefore, the total load on the double 2x12's is:
Tub/deck/4 people:  206 x 2.5 = 515 plf plus
Live load adjacent to tub,
which is 40 psf x 7'/2 =   140 plf plus
Lumber (deck, etc.) 8 psf x 7'/2 = 28 plf for a Total on double 2x12's = 683 plf
If the 2-2x12' are spanning 5', then they'll support about 1,800 lbs. per foot depending on the species and grade of wood. This is also well within a safety factor.
However, the total weight on the 4-4x6's is about 13,400 lbs. / 4 posts = 3,350 lbs. plus about 1,700 lbs. live load for a total load of 5,050 lbs.
The 2x12's are bolted to the 4x6's in a double shear loading pattern. Assuming those are 5/8" bolts, they can only support about 510 lbs. each or about 1,020 lbs. at each 4x6 post.
Summary:
The framing lumber will easily support the required loads, but the connection at the 4x6 posts is grossly inadequate. You'll need to install a 2x6 vertical under each side of each 4x6 that is under the hot tub. Make sure it bears on the footing and fits tight under each 2x12.
Comment: I'd use 16d nails and install 2 about 6" from the top and 2 about 6" from the bottom. Then install them about 16" on center staggered vertically up the posts.
Comment: Hi Lee, Sorry for the lack of weight details, the tub is rated at 6200# with water and cover. I will work my way through your math but I appreciate both the technical break down and the concise summary!
Comment: That's about half the load I calculated. The waterline must be less closer to 2' deep and there's more significant notches for seating, which would reduce the amount of water too.
Comment: What would be an appropriate way to secure the 2x6's into place against the 4x6?

Max Deck Load PSF for Hot Tub


Active Admin custom filter for has many association

Question: I am trying to implement for a custom filter in Active Admin:
The model:
Employer < ActiveRecord::Base
has_many :jobs
has_many :job_applications, through :jobs

Now the model:
JobApplication < ActiveRecord ::Base
belongs_to: jobs

has a status enumeration regarding the status of some application. There are about 8 different fields. I would like to create a filter in ActiveAdmin.register Employer do ... to fetch the number of JobApplciations with a status "employer_accepted".
I have tried using a counter_cache and have read about ransack methods but am struggling to produce something that works. I'm still relatively new to rails so unsure of what to google. If I can give any more information let me know.
Thanks in advance
Answer: I suppose you want to fetch number of JobApplications with a given status employer_accepted.
You can do this using a scope.
Define a scope in your model
app/models/employer.rb:
scope :accepted, -> { joins(:job_applications).where("job_applications.status = 'employer_accepted'")}

Then on the activeadmin page app/models/employer.rb:
scope :accepted, show_count: false


Linearly Independent Vectors--Story Problem

Question: Suppose we have a club with exactly $5$ students. Show, using vectors, that we cannot form $6$ groups so that every two groups share exactly $1$ student.
So if we let $v_1 , \dots ,v_6$ be $6$ linearly independent vectors in $\mathbb{R}^5$, where the $j$'th entry of $v_i$ is $1$ iff student $j$ is in group $i$ and is $0$ otherwise, then we can consider $c_1 v_1+\dots + c_6 v_6=0$ and show that each $c_i=0$. To do this, expanding $(c_1 v_1+\dots + c_6 v_6) \cdot (c_1 v_1+\dots + c_6 v_6)=0$ gives:
$c_1 |v_1|^2+\dots +c_6|v_6|^2+2(c_1c_2 + c_1c_3+\dots +c_5c_6)=0$ since $v_i\cdot v_j=1$ when $i \neq j$.
I cannot figure out how to proceed from here to show each $c_i=0$.
Answer: Basically $\mathbb{R}^5$ can be spanned with 5 independent bases. So, it is impossible to have 6 linearly independent vectors in $\mathbb{R}^5$, because one of them can be expressed as a linear combination of other 5 vectors.
Comment: but how does one arrive at the desired contradiction given the equation present?


How to explain slick.js / slick-theme.css strange dot style loading issue?

Question: In my testing of slick.js front-end slider plugin, I found in Chrome browser, sometimes the navigation dot in class ".slick-dots li button:before"

suddenly changed
from
content: '•';
to
content: '•';
by itself.
However, I wanted the dots
to display
as

instead of

It's wierd when i use incognito to refresh page, it turns back to normal again, but if it already became image 2 via unknown trigger, you are just not able to refresh these dots back to normal in any none-incognito mode;
so what could be the cause of the issue and how to avoid it?
Comment: Can you reproduce it in a [fiddle](http://jsfiddle.net/)?
Comment: as it's not easy to reproduce as i didn't find what triggered it, in chrome also seldom happens. all I noticed is the above css run-time style got changes. the ones i've highlighted in  font-weight
Comment: Unless someone has already run into this issue and knows the solution you won't get any answers from people debugging an image.
Comment: This happens occasionally, a lot of other scripts and css are also loaded with it together in a more complex deployment ,so  it's not easy to purify the scenario and still see the effect, if I got time will try.
Comment: I am running into the same problem -- did you find a fix?
Answer: It's probably caused by your code editor. Make sure u saving file in UTF-8 encoding.
Comment: A Very reasonable answer, yup I am also thinking what could make the chrome browser suddenly change the real-time css character value from '•' to '•' . but I checked in my php header file I've used .
Comment: You need to be really sure that code editor saving file in utf-8 encoding. Meta tag isn't enough.


how to get fourier transform of a signal

Question: In the below code I am trying to get the fourier transform of a stationary signal (x3). But at run time the plot i get is absolutely something wrong and does not show any frequencies of the signals x3.
kindly please guide me and help me to get the fourier transform correctly.
Code:
 %% Time specifications:
  Fs = 8000;                       % samples per second
  dt = 1/Fs;                       % seconds per sample
 StopTime = 1;                    % seconds
 t = (0:dt:StopTime-dt);         % seconds

 x1 = (10)*cos(2*pi*3*(t));
 x2 = x1 + (10)*cos(2*pi*5*(t));
 x3 = x2 + (10)*cos(2*pi*10*(t));

 %% here i try to Plot fourier transform of the signal x3:
 NFFT = 2^nextpow2(StopTime); % Next power of 2 from length of y
 Y = fft(y,NFFT)/StopTime;
 f = Fs/2*linspace(0,1,NFFT/2+1);
 figure;
 plot(f,2*abs(Y(1:NFFT/2+1)));

 %% Plot the signal versus time:
 figure;
 hold on;
 plot(t,x1,'r');
 plot(t,x2,'g');
 plot(t,x3,'b');

Update_1
Comment: Why are you scaling the FFT with `StopTime`? If you want the energy in time domain to equal the energy in frequency domain, you would have to scale by `Fs`.
Answer: You can not see what you expected because the value of NFFT is 1 means when you write NFFT/2+1 as an index of Y it will not be an integer value so MATLAB warns you. You can calculate NFFT like this:
NFFT = 2^nextpow2(length(t))

instead of writing
NFFT = 2^nextpow2(StopTime)

Well, try this:
Fs       = 8000;                 % samples per second
dt       = 1/Fs;                 % seconds per sample
StopTime = 1;                    % seconds
t        = (0 : dt : StopTime-dt);   % seconds

x1 = 10 * cos(2*pi*3*t);
x2 = x1 + 10 * cos(2*pi*5*t);
x3 = x2 + 10 * cos(2*pi*10*t);

%% here i try to Plot fourier transform of the signal x3:
NFFT = 2 ^ nextpow2(length(t));     % Next power of 2 from length of y
Y    = fft(x3, NFFT) / StopTime;
f    = Fs / 2 * linspace(0, 1, NFFT/2 + 1);
figure;
plot(f, 2 * abs( Y( 1:length(f) ) ) ); % // Also try this: plot(f(f <= 200), 2 * abs( Y( 1:length(f(f <= 200)) ) ) )

%% Plot the signal versus time:
figure;
hold on;
plot(t, x1, 'r');
plot(t, x2, 'g');
plot(t, x3, 'b');

Plots:

EDIT:
1- Actually you don' t have to use nextpow() function. If you use it, fft() function works faster. Because, due to time efficiency, fft() works like that recursively divide the signal by 2 for each time. Then calculates discrete fourier transform for each part and gather them. This means that the FFT is most efficient when the signal vector length is a power of 2.
2- Dividing fft result by StopTime part doesn' t make any sense to me either. Dividing fft result by NFFT may be more convenient theoretically.
Comment: You can write "plot(f(f <= 200), 2 * abs( Y( 1:length(f(f <= 200)) ) ) )"
Comment: thank you for the answer. now in the freq. domain, the plot statemnt plot(f, 2 * abs( Y( 1:length(f) ) ) ); generates a graph from zero-4000 on the x-axis. how can i minimize the values on the x-axis to be for an example from 0-200.
Comment: one more question please, why do i need the function nextpow2() i read about in the docs but why do i need it? and why you divided by StopTime in this statement: fft(x3, NFFT) / StopTime
Comment: i wish you saw my questions to you in my previous comment :)
Comment: thanks for updating your answer, kindly please have a look at my update of the question and notice the difference in freq. presentation when i divide by NFFT and when it is ignored.
Comment: @user2121 - You see, the amplitude values make more sense when you divide fft result by NFFT, wrt analytical solution. Spikes look wider place in frequency axis when you divide but actually it is the same with when you dont divide due to scale of amplitute you can not see. You can see there is no differense if you zoom in..


How to solve the drain and sewerage issue along the street curb

Question: Water always fills on our side of the street curb in front of my house. We have a curb drainage hole on this side, but water still fills up the curb on rainy days. During winter, water would freeze and last couple days. It's dangerous to get my mails.
If I want to fix this issue, who I should talk to? Is it my responsibility to consult and find a solution or should I report to the township?
Many thanks!
Answer: That is almost certainly not a pipe that drains into the sewer, but rather a pipe that drains from a downspout or drainage from the yard to the street.
You can talk to the street maintenance department and escalate it up (mayor, alderman, state representative, etc.), but I don't think you will get very far. That will be a very costly change for the city to fix as I think they would need to re-grade the curb quite some distance. No harm in trying, but I wouldn't expect them to fix it at all, let alone quickly, until the street needs repaired/replaced.
My suggestion is a mailbox that opens from the backside as well as the frontside, also known as a double door, two door, or rear access mailbox.
Example:
Comment: @YRJ Legal questions are off-topic here and you would really need to check with a lawyer and that answer can change based on where you live. My expectation is that the icing issue is on the street and not your property, so if anyone is liable, it is the city. It would still be a good idea to notify them of the issue so they know it needs remedied.
Comment: It will be fine as long as it's the responsibility of the township. My concern is I am responsible for someone fall down due to the ice.
Answer: That is an issue to be resolved by the city or municipality where you live.
Email your local representative as well as the Road or works department or whatever entity maintains the roads.
Be sure to include a picture of the water by your mailbox to show your concern.
Be sure to mention the safety issue when it is icy.


How to activate  event by clicking on another element

Question:

    sometext

The link not work (dont open a big image). What i do wrong?
----Edited----
Thank you guys, but .trigger() is not working too. I resolved this problem something like this:
$(document).ready(function() {
            $('div.imgtumb img').click(function() {
            window.location.href = $('a.imgtarget').attr("href");
            });
        });

----Edited 2---
Question which explained why .click() is not working with a tag
Comment: and I found a topic which explained why .click() is not working with  tag - [link](http://stackoverflow.com/questions/1694595/can-i-call-jquery-click-to-follow-an-a-link-if-i-havent-bound-an-event-hand)
Comment: It's probably worth including that link here for others.
Comment: I meant include the URL to the topic :-) If you get 15 reputation you can turn your edit into [an answer to your own question](http://meta.stackexchange.com/questions/132886/what-is-this-answer-your-own-question-jazz).
Comment: o! got it and done :)
Answer: try this:

the event trigger is the event to make another event to an element
http://api.jquery.com/trigger/
Answer: use trigger()

. A call to .trigger() executes the handlers in the same order they would be if the event were triggered naturally by the user:

try this
$('a.imgtarget').trigger('click');

instead of
 $('a.imgtarget').click();

Answer: try to use this instead of .click()
window.open(
  'toBigImg',
  '_blank'
);


Primary ideals of localizations

Question: Let $A$ be a ring and let $S\subset A$ be a multiplicatively closed set. If we denote by $f$ the canonical map from $A$ to $S^{-1}A$ which takes $x$ to $x/1$, then for any primary ideal $\mathfrak{p}$ of $A$ such that $\mathfrak{p}\cap S=\emptyset$, we have a primary ideal of $S^{-1}A$, given by the extension $f(\mathfrak{p})\subset S^{-1}A$ of $\mathfrak{p}$. Is it true that that $f^{-1}(f(\mathfrak{p}))=\mathfrak{p}$?
Comment: I mean **primary**, not prime.
Comment: There have been posters in the past that confused the terms "prime" and "primary". Could you let us know for sure which one you mean? Thanks
Answer: Let $P$ be a prime $a\in f^{-1}(f(P))$, there exists $x$ in $P$ such that $f(a)=f(x)$, we deduce that $f(x-a)=0$ and there exists $s\in S$ such that $s(x-a)=0$. This implies that $sa=sx\in P$. since $P$ is a prime, $a\in P$ or $s^n\in P, n>0$, but $S\cap P$ is empty and $s^n\in S$ since $S$ is a multiplicative family, so $a\in P$. We deduce that $f^{-1}(f(P))\subset P$ and  henceforth is $P$.
Comment: read carefully the definition of a primary ideal.
Comment: I decided to use the bold letters just for this reason...
Comment: Where's the *primary* ideal?
Comment: @Bernard are you speaking with me?
Comment: @VincenzoZaccaro: No, I was asking the question to the author of the answer (I didn't downvote).
Comment: @Tsemo Aristide If I'm not wrong the product $sx$ can belong to $P$ also if we have $x^n\in P$.

Primary ideals of localizations


Can I automatically dispose of refuse into the magma sea?

Question: I've embarked into a mountainous land with no bitumous coal or lignite, and can only find magma in the magma sea. Because of these limitations, I'm going to be migrating my fortress 150 z-levels down; to be closer to my forges (avoiding the fun of magma pump stacks).
My main problem is that 150 squares is a long way to go to put refuse into the outdoor refuse stockpile. Is there some way I can persuade my dwarves to automatically get rid of refuse into the magma sea instead?
Answer: If you mean a normal garbage dumping zone (i.e. for things designated for dumping), it should be possible to do this by creating one in the normal way - I guess the most sensible way would be to create a channel down from above the magma. You may need to disable any other dumping zones you have to stop your dwarves deciding they'd rather go to the surface.
However according to this wiki entry (spoilers beware), note that "any items dropped into the magma sea (specifically, onto "magma flow" tiles above semi-molten rock) will vanish without a trace".
If you mean for general refuse, I don't think there's a way to dump this automatically. You could keep a refuse stockpile near your magma dump and manually designate things for dumping now and then, but that may be a hassle. Alternatively you could just create a larger indoor refuse pile with appropriate precautions for sealing the resulting miasma inside the stockpile, let the majority of refuse rot away and use any bits that don't in crafting (bones, shells etc).
Comment: I didn't know about indoor refuse stockpiles. Very interesting. I've removed the use of 'dump' in my question to avoid ambiguity.
Answer: I believe what you can do is channel a hole above the magma sea, build a trapdoor over it, then designate that trapdoor as a garbage dump. Put it in a small room by itself, with a door. Then build a lever outside the room and link it to the trapdoor. When you designate something for dumping, it will be placed on the trapdoor. When everyone is out of the room, lock the door (to make sure no one is standing on the trapdoor) and tell a dwarf to pull the lever, dumping the garbage dump into the magma sea. Also, the door will prevent miasma spreading into the rest of the fortress, should you choose to dispose of refuse and corpses this way.
Comment: I reckon the pressure plate idea will result in a mess of job interrupts, which is far worse than dwarf casualties. More importantly, this whole idea just adds an unnecessary step to the process - if a dump zone borders a hole, items will be automatically thrown down the hole.
Comment: That doesn't seem very automatic at all...
Comment: Well, you have to make a trade-off between automation and safety. You could make it more automatic by placing a pressure plate in a heavily traveled area, and linking that to the trapdoor. Then it would be constantly dumping anything on it into the magma. However, you are very, very likely to also dump dwarves that way.
Comment: Ah, true. I hadn't put much thought into it, as I didn't consider it a useful idea. Also, I was unaware of the whole 'dump zone bordering a hole' thing, good to know!
Answer: Maybe Minecarts could be helpfull? If you know how minecart railgun works You could make minecart refusegun :). You could shoot refuse into magma, outside area, or closed room. You could even kill some goblins using refuse :D
Comment: Hi Phyropylus. If you haven't already, check out the Arqade help centre regarding [answers](http://gaming.stackexchange.com/help/how-to-answer) - it is really useful. Hope you enjoy your stay.
Answer: Although you can design your fortress to dump refuse into the magma sea, it's probably less trouble to instead build a Dwarven Atom Smasher. Atom Smashers have the advantage of not requiring a path to the magma sea; they can be built anywhere. To build one requires only a lever attached to a drawbridge (two mechanisms are also required), where the open drawbridge lays flat on one or more tiles where you designate a dump area. When the drawbridge is opened, it smashes all items under it into oblivion.
Advantages of using an Atom Smasher (rather than the magma sea) to get rid of trash:
1) Avoid the 'fun' of creatures that live in the magma sea entering your fortress.
2) No need to create a chute or other way to get refuse down multiple Z levels to the magma sea.
3) Artifact items may not be destroyed in the magma sea; these undestroyed items will lower game FPS since the game still tracks them.
Disadvantage of using an atom smasher:
1) One of your dwarves needs to pull the drawbridge lever now and then to destroy garbage.
2) Dwarves standing too close to the dump point may be obliterated when the drawbridge is dropped.


Spring Boot, Jolokia Remote Access returns No 'Access-Control-Allow-Origin' header is present

Question: I setup jolokia with jmx on my spring boot application, so I can get jmx information over HTTP.
However I can't get the data by javascript ajax with the error "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."
I want to make jolokia endpoint return 'Access-Control-Allow-Origin: *' header to allow any origin or at lease return the header with allowed origin I specified on jolokia-access.xml, but I don't get the header on response and I'm not sure what I missed
The monitoring javascript I'm running is not on same server which has my spring boot application, since I want to make the script run remotely.
Below is my spring boot application setup.
application.properties and jolokia-access.xml both are in classpath, so I can see the change I made for management.port on application.properties and remote post access restriction on jolokia-access.xml are applied
pom.xml
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.4.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </dependency>
        :

application.properties
management.port=8888

endpoints.jolokia.path=/jolokia
endpoints.jolokia.enabled=true

endpoints.jmx.enabled=true

endpoints.cors.allowed-origins=*
endpoints.cors.allowed-methods=*
endpoints.cors.allowed-headers=*

jolokia-access.xml
<?xml version="1.0" encoding="UTF-8"?>
<restrict>
    <remote>
        <host>127.0.0.1</host>
        <host>localhost</host>
    </remote>

    <http>
        <method>post</method>
        <method>get</method>
    </http>

    <commands>
        <command>read</command>
        <command>list</command>
        <command>version</command>
    </commands>

    <cors>
        <allow-origin>http://localhost:*</allow-origin>
        <allow-origin>http://127.0.0.1:*</allow-origin>
    </cors>
</restrict>

When I hit the jolokia endpoint by curl, I can have jmx data on response as json like below
$ curl -X POST http://127.0.0.1:8888/jolokia -d '{
    "type":"read",
    "mbean":"org.springframework.boot:type=Endpoint,name=healthEndpoint",
    "attribute":"Data"
}'
{"request":{"mbean":"org.springframework.boot:name=healthEndpoint,type=Endpoint","attribute":"Data","type":"read"},
"value":{"diskSpace":{"threshold":10485760,"free":204441415680,"status":"UP"},"db":{"database":"H2","hello":1,"status":"UP"},"status":"UP"},
"timestamp":1433908260,"status":200}

$ curl -X POST http://127.0.0.1:8888/jolokia -d '{
    "type":"read",
    "mbean":"java.lang:type=Memory",
    "attribute":"HeapMemoryUsage",
    "path":"used"
}'
{"request":{"path":"used","mbean":"java.lang:type=Memory","attribute":"HeapMemoryUsage","type":"read"},
"value":69036712,"timestamp":1434075946,"status":200}

However below javascipt failed since resposne from jolokia endpoint doesn't have Access-Control-Allow-Origin' header.
Even if I setup 'endpoints.cors.allowed-origins=*' properties, but I don't see the header on the response
Monitoring javascript
var j4p = new Jolokia({url: "http://127.0.0.1:8888/jolokia", fetchInterval: 1000});

var context = cubism.context()
    .serverDelay(0)
    .clientDelay(0)
    .step(1000)
    .size(594);
var jolokia = context.jolokia(j4p);

var memory = jolokia.metric(
    function (resp1, resp2) {
        return Number(resp1.value) / Number(resp2.value);
    },
    {type:"read", mbean:"java.lang:type=Memory", attribute:"HeapMemoryUsage", path:"used"},
    {type:"read", mbean:"java.lang:type=Memory", attribute:"HeapMemoryUsage", path:"max"}, "Heap-Memory"
);

Request header the javascript sent
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:127.0.0.1:8888
Origin:http://127.0.0.1:8080
Referer:http://127.0.0.1:8080/monitor/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36

Response header the javascript received
Allow:GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Cache-Control:no-cache, no-store, max-age=0, must-revalidate
Content-Length:0
Date:Fri, 12 Jun 2015 02:27:17 GMT
Expires:0
Pragma:no-cache
Server:Jetty(9.2.10.v20150310)
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-XSS-Protection:1; mode=block

As you see above, there is no 'Access-Control-Allow-Origin' header at all.
Comment: The `endpoints.cors.*` properties are new in Spring Boot 1.3.0 so they won't work with 1.2.x
Comment: Isn't there any way to enable cross origin for jolokia on spring boot in version 1.2.4 which is latest release version? If there is no way, then we cannot use javascript to access jolokia.  I checked enabling cross origin by introducing filter for spring mvc (https://spring.io/guides/gs/rest-service-cors/ ) and tried, but I found that it is just enabling cross origin only on my spring boot app, not on jolokia
Comment: I tested this again with updating my project to Spring Boot version 1.3.0.RELEASE and checked this issue has been resolved when I setup below properties on application.properties file.                endpoints.cors.allowed-headers=*  endpoints.cors.allowed-methods=*
endpoints.cors.allowed-origins=*
Answer: By default, Jolokia allows any cross origin access. So there is no need for a jolokia-access.xml at all.
On the other hand, I think your pattern should work. But please raise an issue on GitHub so that we can continue there to fix this.
Comment: I loaded up my code onto GitHub ( https://github.com/wsapiens/jolokia ) so people can look into. please let me know if that is not good enough and I should take more action
Comment: I create issue on GitHub ( https://github.com/rhuss/jolokia/issues/202 ) for this issue.


Application of Borel-Cantelli lemma

Question:
Let $\{X_1,X_2,\dots\}$ be a sequence of i.i.d. random variables. Define $M_n=\sup\limits_{k\leq n} |X_k|$. Suppose $X_1$ is $p-$th integrable i.e. $E[|X_1|^p]<\infty$ for some $p\in(0,\infty)$. Show that
$\frac{1}{n^{1/p}}M_n\to 0$
with probability 1.

I have already proven that for an integrable random variable $X$,
$\sum\limits_{n=1}^\infty P(|X|\geq \epsilon n)<\infty$
Hence to prove the statement, let $\epsilon >0$. Define $A_n=\{|X_n|\geq \epsilon n^{1/p}\}$.
Then $\sum\limits_{n=1}^\infty P(A_n)=\sum\limits_{n=1}^\infty P(|X_n|\geq \epsilon n^{1/p})\leq \sum\limits_{n=1}^\infty P(M_n\geq \epsilon n^{1/p})$
I want to show that $\sum\limits_{n=1}^\infty P(A_n)<\infty$ and then use the Borel-Cantelli lemma to show $P(\limsup A_n)=0$.
I don't know how to show $\sum\limits_{n=1}^\infty P(M_n\geq \epsilon n^{1/p})<\infty$. I don't know how to use the condition that $X_1$ is p-th integrable.
Answer: Since the $X_j$ are identically distributed, $\mathbb{P}(|X_n| \geq \epsilon n^{1/p}) = \mathbb{P}(|X_1| \geq \epsilon n^{1/p}) = \mathbb{P}(|X_1|^p \geq \epsilon^pn)$. Then as $X_1$ is $p$-th integrable from what you've already shown $\sum_{n=1}^{\infty} \mathbb{P}(|X_n|^p \geq \epsilon^pn) = \sum_{n=1}^{\infty} \mathbb{P}(|X_1|^p \geq \epsilon^pn) < \infty$ so, as you noted, by Borel-Cantelli $\mathbb{P}(\lim \sup A_n) = 0$.
Now we argue that the event $\{\lim_{n \to \infty} \frac{1}{n^{1/p}}M_n < 2 \epsilon \}$ contains the complement of $\lim \sup A_n$ and in particular has probability $1$.
Suppose $\omega \not \in \lim \sup A_n$. Then $|X_n(\omega)| < \epsilon n^{1/p}$ eventually, say for $n \geq N$. So $\frac{1}{n^{1/p}}M_n(\omega) < \frac{1}{n^{1/p}}\max_{k < N} |X_k(\omega)| + \epsilon$ for any $n \geq N$. But since the $\max$ is over finitely many terms the first part of the right hand side tends to $0$ as $n \to \infty$ so there is an $M$ such that for $n \geq M$, $\frac{1}{n^{1/p}}\max_{k < N} |X_k(\omega)| < \epsilon$. Hence for $n \geq \max\{M,N\}$ we have that $\frac{1}{n^{1/p}}M_n(\omega) < 2 \epsilon$ so $\omega \in \{\lim_{n \to \infty} \frac{1}{n^{1/p}}M_n < 2 \epsilon \}$.
To conclude, let $B_k = \{\lim_{n \to \infty} \frac{1}{n^{1/p}}M_n < \frac{2}{k} \}$. By taking $\epsilon = \frac{1}{k}$ in the above $\mathbb{P}(B_k) = 1$ for each $k$ so $\mathbb{P}(\bigcap B_k) = 1$. But since $M_n \geq 0$, $\bigcap B_k = \{\lim_{n \to \infty} \frac{1}{n^{1/p}}M_n = 0 \}$
Edit: I've realised that a problem with the original answer that I give above is that it presupposes the existence of the limit in the third paragraph. An easy fix for this is to just look at the set $\{\lim \sup_{n \to \infty} \frac{1}{n^{1/p}}M_n < 2 \epsilon \}$ instead and then all of the above argument goes through.
Comment: Note that $\frac{1}{n^{1/p}} |X_j(\omega)| < ...$ for each $j$ then just take the $\sup$ on the left hand side.

Application of Borel-Cantelli lemma


A 'typedef' for a template function (boost::make_shared)

Question: I'm migrating my project to C++11 and I'm trying to use as much of standard library as possible.
Before I finalise the migration, I need a quick way to flip between boost and STL implementation of shared_ptr (to do benchmarks, unit tests etc).
So I defined an alias for shared_ptr like this:
#ifdef _USE_BOOST_
template <class C>
using shared_ptr = boost::shared_ptr<C>
#else
template <class C>
using shared_ptr = std::shared_ptr<C>
#endif

now I need to do the same for make_shared... But how? Macro? A wrapper? I don't really like either of them. What are the alternatives?
Comment: You don't have much choice but to write a quick wrapper.
Answer: Using variadic templates and perfect forwarding:
template<typename C, typename...Args>
shared_ptr<C> make_shared(Args &&...args) {
#ifdef _USE_BOOST_
  return boost::make_shared<C>(std::forward<Args>(args)...);
#else
  return std::make_shared<C>(std::forward<Args>(args)...);
#endif
}

Comment: I'n pretty sure copy will optimized out
Comment: With c++11 no copy will be made, in the worst case it will be `moved` out, but more likely return value optimization kicks in.
Comment: Was exactly the answer I was writing, but you beat me to it.
Comment: This is what I did, but I don't like the fact that resulting `shared_ptr` is copied twice.
Comment: Accepting as this is a perfectly valid answer. I don't have any other options it seems


Exercise 2.3.5 in Vershynin's HDP book

Question: Let $X_i$ be independent Bernoulli random variables with parameters $p_i$. Consider their sum $S_N=\sum_{i=1}^N X_i$ and denote its mean by $\mu=\mathsf{E} S_N$. Then, for $\delta\in (0,1]$, prove that
$$\mathsf{P}\{|S_N-\mu|\geqslant \delta\mu\}\leqslant 2e^{-c\mu\delta^2}$$
where $c>0$ is an absolute constant.
This is the Exercise 2.3.5 in Vershynin's HDP book. My idea and problem are as following:
============================  My Solution ============================
I use the following two inequalities:
1.[Chenoff's inequality] $$\mathsf{P}\{S_N\geqslant t\}\leqslant e^{-\mu}\left(\frac{e\mu}{t}\right)^t,\qquad (t>\mu)$$
2.[Extension of Chernoff's inequality, see Exercise 2.3.2 in Vershynin's HDP book] $$\mathsf{P}\{S_N\leqslant t\}\leqslant e^{-\mu}\left(\frac{e\mu}{t}\right)^t,\qquad (t<\mu)$$
Then I get
$$
\begin{aligned}
\mathsf{P}\{|S_N-\mu|\geqslant \delta\mu\}&\leqslant \mathsf{P}\{S_N-\mu\geqslant \delta\mu\} + \mathsf{P}\{\mu-S_N\geqslant \delta\mu\}\\[0.5em]
&=\mathsf{P}\{S_N\geqslant (1+\delta)\mu\}+\mathsf{P}\{S_N\leqslant (1-\delta)\mu\}\\[1em]
&\leqslant e^{-\mu} \left\{\left(\frac{e}{1+\delta}\right)^{(1+\delta)\mu}+\left(\frac{e}{1-\delta}\right)^{(1-\delta)\mu}\right\}.\qquad[\text{use ineq. 1 & 2 above}]
\end{aligned}
$$
============================ My Problem ============================
However, I cannot prove that
$$
e^{-\mu} \left\{\left(\frac{e}{1+\delta}\right)^{(1+\delta)\mu}+\left(\frac{e}{1-\delta}\right)^{(1-\delta)\mu}\right\} \leqslant 2e^{-c\mu\delta^2}.\tag{*}
$$
Is the ineq. (*) true?
Answer: It can help to write down the desired inequality and work backwards.
\begin{align}
e^{-\mu} (e/(1+\delta))^{(1+\delta)\mu}
&\le e^{-c \mu \delta^2}
\\
\delta + c \delta^2
& \le (1+\delta) \log(1+\delta)
& \text{take logarithms, rearrange}
\end{align}
Use Taylor's theorem to approximate $\log(1+\delta)$ with $\delta + c' \delta^2$.
The other inequality $e^{-\mu} (e/(1-\delta))^{(1-\delta)\mu} \le e^{-c\mu \delta^2}$ can be handled similarly.

Exercise 2.3.5 in Vershynin's HDP book


Optimal percentages for maximum profit and experience when buying and selling for each customer

Question: Does anyone know the optimal buying/selling percentages of normal, increased and decreased-priced items to get the maximum experience points (high chance of pin bonus and customers should accept at first offer - no haggling; to get the maximum number of Just Combo bonuses possible) for each customer in the game (including Euria) while making profit as high as possible (prioritize experience)?
I have just finished the game and I am now trying to reach a high merchant level while trying to make the item inventory well stocked with items so I can play a 'New Game+' easily to get another adventurer's True Card.
Also, I would like to know the optimal buying/selling percentages for maximum profit, while making the customer not haggle and making the experience as high as possible (prioritize profit over experience).
Capitalism, Ho! Y'all!
Edits:
I found a Pin Bonus guide here: http://recettear.wikia.com/wiki/Pin_Bonus_Percentages but the data for some of the customers are missing (some are even wrong), and there is no data at all for decreased-priced items. (Although this maybe because it was written for the demo version of the game.) I am playing the Full version with the current latest v1.108 patch.
The 'always-sell-at-104%' technique mentioned in the link I put above and FallenAngelEyes' link in the comments works fine for getting maximum experience points when buying normal-priced items. I was wondering if this could be increased for some of the customers to get more profit while still maintaining a good chance of hitting the Pin Bonuses and Just Combo chains. Also, I need optimal buying/selling info for Euria, who was probably put in the game to break Just Combo chains. I also would like to know the elusive buying/selling info for increased-price and decreased-price items for all customers.
Comment: possible duplicate of [How do you gauge the Near Pin % of a transaction?](http://gaming.stackexchange.com/questions/7383/how-do-you-gauge-the-near-pin-of-a-transaction)
Comment: As a comment, as I was the one who asked the linked question above, I can verify that the suggested 104% target works *very* well for XP gain purposes (chaining pin bonuses). In terms of monetary gain, that I cannot speak for.
Comment: It looks like from galacticninja's question that the linked question does not account for all possible customers (though it does an adequate job for those characters present in the demo).
Comment: I think I remember reading that the customer preferences regarding prices are different for every game, though each individual holds to their own preference throughout it.
Answer: Look first off, you don't really need to be too precise. The main thing is to only buy blue reduced items from the wholesellers. And then try really hard to only sell pink "in demand" items (these will sell for over 200%). Working like that, you will smash the final week target easily. When you sell e.g. an order of 3 things with a description of e.g. "something metal" to the Old Man, he will accept 240% for each, and you bought them for e.g 33k and are selling them for 100k each, you can make some massive profits.
For experience the main thing is to make sure that you get a lot of customers in for each session. Make sure the shop is stocked with some cheap crap, food is good, and in the middle of the style scale e.g. not too gaudy and then you will get a lot of customers. I also put expensive stuff in the shop window. Then you will hit regularly hit 128 XP.
The actual answer to your question is beyond me now. I wrote out all the percentages but then deleted the file because the end game is a bit of a grind and I knew I wasn't coming back. I found that, of course, the old man is more generous than the little girl, however, as well as this, I seem to remember that what they said was really important. Each type of shopper has their own little sayings e.g. they will come to the counter and say something and the thing that they say determines the price that they are willing to pay, so what I did was write out each and every sentence and used trial and error to work the optimum percentage for each sentence. If they tried to haggle then next time they used that same sentence, I would lower the percentage a little bit, and I continued like that until they accept the price without haggling.
Answer: Aiming for for the 104-108% sell price isn't just for getting your xp bonuses maxed.  In fact, a more important outcome is getting those little hearts.  Every time you get a heart you have leveled your relationship with that customer.  In so doing you increase the amount of money they bring into the store (by x10?  I can't recall).  This is crucial because if you don't do this customers won't have enough money to buy and sell the expensive stuff you need to move to hit the targets.
Also, DanD is correct.  The best way to make money is to buy items when they are in low demand (blue colored) and then sell them when they are pink.  But you don't need to wait for that swing.  Going blue -> normal or normal -> pink will make you a ton of money.  Once you are selling the top tier items, you can't help but rake it in.
Comment: Good answer. I wish I could have two accepted answers here.
Answer: This is still in progress of checking but, here:
Customer price data (Haggle usually, once at most)

Name
Price Factor
Randomness
Purchase Factor

Tear
130%
±2%
35%

Louie
120%
±2%
45%

Charme
125%
±2%
40%

Caillou
135%
±3%
30%

Tielle
135%
±3%
30%

Elan
135%
±3%
30%

Nagi
135%
±3%
30%

Griff
135%
±3%
30%

Arma
135%
±3%
30%

Guildmaster
130%
±1%
35%

Woman
120%
±3%
45%

Man
130%
±4%
35%

Old Man
125%
±8%
40%

Girl
115%
±1%
50%

Euria
N/A
±5%
200%

Alouette
150%
±1%
15%

Prime
105%
±1%
60%

If you want to haggle, set your starting sale price at about 3%-5% higher than how much you want to sell it at first. Buying works similarly.
Customer price data (Combo, Sell)

Name
Near Pin (Sell)
Just Pin Range (Sell)
Just Combo (Sell)

Tear
108%
104%-108%
108%

Louie
108%
104%-108%
108%

Charme
108%
104%-108%
108%

Caillou
108%
104%-108%
108%

Tielle
108%
104%-108%
108%

Elan
108%
104%-108%
108%

Nagi
108%
104%-108%
108%

Griff
108%
104%-108%
108%

Arma
108%
104%-108%
108%

Guildmaster
108%
104%-108%
108%

Woman
108%
104%-108%
108%

Man
108%
104%-108%
108%

Old Man
108%
104%-108%
108%

Girl
108%
104%-108%
108%

Euria
N/A
N/A
N/A

Alouette
108%
104%-108%
147%

Prime
102%-104%
102%-104%
104%

They'll buy at once at these prices. If you're lucky, you'll get a Near Pin or a Just Bonus.
Customer price data (Combo, Buy)

Name
Near Pin (Buy)
Just Pin Range (Buy)
Just Combo (Buy)

Tear
70%
67%-70%
70%

Louie
70%
67%-70%
70%

Charme
70%
67%-70%
70%

Caillou
70%
67%-70%
70%

Tielle
70%
67%-70%
70%

Elan
70%
67%-70%
70%

Nagi
70%
67%-70%
70%

Griff
70%
67%-70%
70%

Arma
70%
67%-70%
70%

Guildmaster
70%
67%-70%
70%

Woman
70%
67%-70%
70%

Man
70%
67%-70%
70%

Old Man
70%
67%-70%
70%

Girl
70%
67%-70%
70%

Euria
350%
350%-360%
210%

Alouette
70%
67%-70%
20%

Prime
70%
67%-70%
70%

They'll sell at once at these prices. If you're lucky, you'll get a Near Pin or a Just Bonus.


Secure the High Kingdom of the North Sea: What does "England must be departitioned" mean?

Question: I am playing Crusader King 3 with the Northern Lord flavor pack. There is a decision to "Secure the High Kindom of the North Sea".
One requirement reads:

The Danelaw currently has De Jure Counties, and England must be departitioned first

I am currently King of Norway, Denmark, and England as well, trying to hold it for 30 years. Now I realize I also have to fullfill that requirement and I have no clue what it entails.
What does departitioning England mean? (The Danelaw already exists. I am fighting with them for the North Sea Heartlands as well.)
Answer: The requirement means:

England must have had a de jure partition split, meaning the Danelaw and England coexist
afterwards you still have to usurp the remaining Danelaw. (I conquered England when the Danelaw existed already. I don't know if it could work with conquering England as an Danelaw King)

Once I conquered all of the remaining Danelaw territory, an event appeared proclaiming that the Danelaw title was destroyed and all Danelaw claimants lose their claim, only England remains.


What is the maximum size of an independent set in the following tree?

Question: I am trying to solve this and getting 7 as an answer, but can anyone confirm my answer?
Answer: The maximum size of the independent set in this tree is 10.
This can be obtained by the following dynamic programming over tree: for each vertex, we will calculate the maximum independent set of a subtree of this vertex with this vertex included and without. Then, if this vertex is not included we will pick a maximum of 2 values from each child and sum them, and for this vertex included we pick non-included values from children, sum them and add 1 (current vertex). For leaves, our dynamic programming is, obviously, (0, 1).
That is my manual calculation of this dynamic programming. Values are written in the form (not included, included) near each vertex, and colored vertices are the maximum independent set.


Replacing outlet with GFCI outlet, preexisting GFCI outlet quit working

Question: I replaced an outlet with Line & Load wires in Rm-A with a GFCI outlet. The new outlet won't RESET and a preexisting GFCI outlet with Line wires only in Rm-B quit working. Each outlet is on a different breaker. When I tried replacing the outlet in Rm-B with a standard outlet thinking its power might be coming from the outlet in Rm-A, neither outlet worked.
Comment: Normal outlets don't have LOAD wires.  All wires are LINE.  You are confusing a GFCI instruction, which is to use the LOAD terminals for circuit extensions **that you want to GFCI-protect**.  *You* should never use the LOAD terminals for anything.
Comment: can we have a picture please
Comment: What is "Line & Load" in your terminology ? Is the line the Hot one (has power)
Comment: We don't know the year so no handle tie may have been required. As for the other question line is the side connecting to the panel or incoming hot, the load side is the secondary or hot going to additional devices that need protection.
Comment: Are both breakers together in the panel?  Would you know if one breaker has a red(or not black) wire on the breaker?
Comment: To me it sounds like they are both on the same breaker. If this is true and the hot incoming power is to the line side of A and the output to the B is on the load, the self test feature in B receptacle is tripping A , I would check the actual embossed line and load markings on the GFCI's if on the same breaker or a multi wire branch circuit , GFCI's don't play well together.
If you want multiple GFCI's on 1 branch circuit use the line to A and B . Photos of your wiring will be helpful and not all GFCI's have line and load in the same location , some are reversed.
Comment: @EdBeal different breakers suggests to me either a MWBC that is missing a handle-tie, or an incompetent "poached neutral" situation where the downline outlet grabs neutral from another circuit (wire fire waiting to happen).
Comment: The breakers are not together.  Rm-A is on # 27, 1st column in the breaker box, Rm-B's breaker, #28, is on the second column if the breaker box.
Answer: TLDR: If you didn't realize GFCIs could protect other outlets, don't use "Load". The "Line" terminals can take 2 screws - read the instructions.
You should not use "Load"
I get it, it's a common thing, you have 4 wires to attach and you see 4 screws, so there's a sense of symmetry. And the instructions seem to say to do that.  And who reads warning tape? LOL, I'm sure that's merely decorative!
"Load" actually does something very special, and you're not supposed to use it for anything else.   As you perfectly well know, there is a GFCI module inside this gadget which protects the two sockets. Well if it can protect 2 sockets, why can't it protect 3 or 4, or 10?  The "Load" terminals are to allow you to do exactly that.  The extra sockets can be attached to this GFCI (and receive its protection) by connecting their hot and neutral to the GFCI "Load" terminals.
I bet you didn't even know GFCIs had that feature :)
This is a nice money saver when you can use it - but with great power comes great responsibility.  You must - this is a Code requirement - you MUST know each and every outlet that is being fed off those "Load" terminals. You must identify them, and  you must label them "GFCI Protected" (and "No Equipment Ground" where applicable). NEC 110.3(B), instructions 8(C).  While this identification rule sound pedantic, it actually solves many problems, but mostly makes you think about what you are doing.
This is the only proper use of "Load".  Where you went off the rails is you used those terminals for no good reason - you just needed a place to land 2 more wires.  Mistake. The right thing to do is to attach both wires to "Line" - the terminals take 2 wires, the instructions say how.
When you have no interest in having the GFCI protect other outlets, and no interest in mapping and labeling those outlets, just don't use Load.  Most people don't even realize GFCIs can do that, and expect to put a GFCI receptacle at every location - that is fine but they should never use Load. If I were king, I'd have 4 screws, all Line, and the "Load" terminals would be concealed and only electricians would know they were there.  As built, GFCIs are very DIY-hostile.
And I'll say one more thing.  Never using Load and just fitting a GFCI receptacle everywhere you want protection, is fine in most cases IMO. Using downline protection can be big trouble (especially if done by accident) -- we hear many cases where someone had an outlet "go dead for no reason", and paid an electrician $150 only to be shown a tripped GFCI elsewhere.  "Thanks a lot, LOAD terminals!"  Maybe never using them is better.
At the very least, while you are marking the receptacles "GFCI Protected", use a P-touch label maker and also state where the reset is.
<code>   GFCI Protected
   Reset in hallway
</code>
A Multi-Wire Branch Circuit requires special handling
You say that this breaker tripping breaks stuff on another circuit.  That is one of two things. Either

The other outlet is illegally crossing neutral with this circuit, taking hot from another circuit but stealing neutral from this circuit instead of its own circuit. That sounds super clever until you realize neutrals don't have circuit breakers. Nothing protects neutral from overload, except faithful matching of hot to neutral (so all neutral current comes through the same hot breaker).
The 2 hot wires are part of a legal, approved way of sharing a neutral wire, called a Multi-Wire Branch Circuit or MWBC.  However, MWBCs require carefully following several rules to avoid overloading the neutral or shocking maintainers, and those are not followed.

A MWBC involves a 3-wire cable (black white red) coming from the panel to outlets.  Let's go through the rules of MWBC.
Rule 1: Neutral must be pigtailed (the way ground is).
You are not allowed to use the 2 screws on a receptacle as a way to splice the neutral wire onward to other parts of the MWBC.  That is because if someone removed the device (or put a GFCI there LOL), that would cut neutral to the onward part of the circuit.  This is very bad. Due to how power works, the neutral on the far side of the cut will now be HOT.  For instance you can get shocked changing a bulb (the shell of an Edison bulb is hardwired to neutral).
So using the regular receptacle as a neutral splice was bad, and using the GFCI Line/Load neutral as a splice was of course a disaster.
Rule 2: Breakers must be handle-tied
Think about what I said about the neutral on the far side of the cut being hot. That means right now, in the box you are working on, the neutral on the Load terminal is hot (if any loads on the other half-circuit are switched on).  Because when you hunted down the breaker for "this circuit", you never thought you'd need to shut off any other breakers to make the box safe!
And this is why Code requires that all breaker handles on a MWBC must be handle-tied. The breaker manufacturer makes UL Listed handle-ties for their breakers, or you can simply use a 240V/2-pole breaker that has a built-in handle-tie (or only one handle in the case of "QO").
So you should identify all your MWBCs and handle-tie the breakers or replace with 2-pole 240V breakers (not to be confused with independent-handle tandems, which would be Very Bad for MWBC).
Rule 3 (most important): Must be on opposite poles
The two hots must be 240V apart!  (or 208V in 3-phase country).   This is because of the electrical sleight-of-hand the MWBC uses to support 2 hots on 1 neutral without overloading it.   (see link in previous paragraph for a long discussion on poles).
When the hot wires are on opposite/different poles, with 240/208V between them, the neutral wire carries only differential current (12A on one, 15A on the other, neutral is 3A).
When the hot wires are on the same pole (0V between hots), the neutral carries the sum of currents (12A on one, 15A on the other, neutral is 27A - whoops!)
Use of a 2-pole breaker will guarantee correct phasing. And so will using a handle-tie in most cases.  (GE panels are an exception here, as on their "thins" the hendle tie is no help at all, and their 2-pole "thin" can be forced into the wrong position.)
Rule 4: You can't use GFCI "load" on a MWBC
Aside from violating rule #1 about pigtailing neutral, it simply won't work. The GFCI will see the neutral sharing as imbalance current, and will trip.
Comment: +1 for "As built, GFCIs are very DIY-hostile." This is too true. - Just providing four LINE screws, even without hiding the LOAD screws, would be so much clearer.
Comment: I wish I could give you another +1 for the "GFCI Protected -- Reset at " label.
Comment: I have some understanding of the effect of using the LOAD screws; replaced an outlet with GFCI in kitchen cabinet area making sure to place in first in the sequence of three outlets. That all worked fine.
Comment: @LauraLou then what's probably news to you is that you have an MWBC (or a badly miswired circuit). Using "Load" on MWBCs is hopeless because you can't share the neutral on the Load side of the GFCI - nevermind the pigtail rule, the GFCI *won't let you*.
Comment: Well, Thank You everyone for the explanations. Am getting an electrician out to take a look. Not happy, but prefer Safe


why Ubuntu command prompt is not prompting after executing the mail command?

Question: <code>uuencode text.txt | mail -s "hai" "firstname.lastname@example.com" < body.txt
</code>
after executing this command, terminal is blank. It is not prompting for next command. I have to press ctrl+z to return to terminal.
What could be the problem?
Answer: Well, you don't do it this way ;-) Nice try though!
You are using the pipe "|" to write the output of your uuencode command to the input channel (aka. stdin, standard input) of the mail command. You are also using the shell redirection "<" to write the file contents of body.txt to the input channel of you mail command.
This is ambiguous. I am not sure right now, what takes precedence, or how the shell handles the situation. You probably end up with one of the programs asking for input.
Better clarify for the shell, what to do, in what order. I.e. by writing:
<code>(cat body.txt; uuencode text.txt) |mail -s "hai" "email@example.com"
</code>
This executes cat (the file printer) and uuencode in one rush (in a subshell to be precise, due to the parenthesis) and pipes the common output to the mail program
Comment: I have tried what you told.But it is still showing the same blank page. pls tell me another solution. thank you
Comment: Odd..., after rereading the man page, maybe use a plain `echo` to make  sure the input ends with a newline, before stdin for the mail program is closed: `(cat body.txt; uuencode text.txt; echo) |mail -s "hai" "email@example.com"`


why we use double slash instead http

Question: I see some web pages that link javascript file to page like this :

Why we use double slash ( // ) instead http:// or https:// from beginig absolute url ? what's different ?
Answer: the protocol will be inherited from whichever page you're on. If your site can be on different protocols - http on the homepage, https on account pages, for example - then you won't have to worry about potentially loading "insecure content."
Comment: You can use `https` from regular http pages.  Upgrading to https is OK, its downgrading that give the warning/error.
Comment: @JeremyJStarcher - right. The main concern would be loading `http` over `https`
Answer: The difference is that by not specifying a particular protocol, the script will load using the same protocol used to load the page itself. This has advantages when the page is accessible through more than one protocol (e.g., both http: and https:).
For more information see RFC 3986, Section 5.2: Relative Resolution of URIs.

why we use double slash instead http


Error installing Pycharm 4.0.4 Pro in Fedora 21

Question: I am very new to using a linux system, I am getting the ERROR while installing PyCharm but unable to sort it out. If possible please help.
[ace139@localhost pycharm-4.0.4]$ cd bin
[ace139@localhost bin]$ ls
fsnotifier       inspect.sh              log.xml              pycharm.sh
fsnotifier64     libyjpagent-linux64.so  pycharm64.vmoptions  pycharm.vmoptions
idea.properties  libyjpagent-linux.so    pycharm.png
[ace139@localhost bin]$ ./pycharm.sh
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
[    200]  ERROR - nse.impl.GeneralLicenseManager - No valid license found
java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)
    at com.intellij.ide.a.g.bb.a(bb.java:107)
    at com.intellij.idea.MainImpl$1.start(MainImpl.java:47)
    at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:105)
    at com.intellij.idea.MainImpl.start(MainImpl.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:91)
    at java.lang.Thread.run(Thread.java:745)
[    201]  ERROR - nse.impl.GeneralLicenseManager - PyCharm 4.0.4  Build #PY-139.1001
[    201]  ERROR - nse.impl.GeneralLicenseManager - JDK: 1.8.0_31
[    202]  ERROR - nse.impl.GeneralLicenseManager - VM: OpenJDK 64-Bit Server VM
[    202]  ERROR - nse.impl.GeneralLicenseManager - Vendor: Oracle Corporation
[    202]  ERROR - nse.impl.GeneralLicenseManager - OS: Linux

Answer: There is an article dealing with this problem. http://oonlab.com/fix-install-pycharm-fedora-21.onto/
TLDR:
sudo dnf install java-1.8.0-openjdk

Tested by myself on Fedora 21 and PyCharm 4.
Answer: Try doing a backup of ~./.PyCharm40 and remove that directory.
Answer: I was having same issue, try
yum install java-1.7.0-openjdk-devel

this will fix your problem


split the data into separate file after encountering a column name

Question: eno,ename,
101,'sam',
102,'bill',
eno,ename,
103,'jack',
eno,ename,
104,'pam',

I have a huge .csv file in which column names reappear after certain number of rows. is there a way in python to split such data into multiple files as soon as it encounter the "repeated column names"?
I would like the above data to be in 3 separate .csv files since the same column names appear 3 times.
Answer: Challenging! Here's my solution. There is likely a more straightforward way to do this though.
with open("./file.csv", "r") as readfile:
    file_number = 0
    current_line_no = 0
    tmpline = None

    for line in readfile:

        # count which file you're on. Also use write mode "W" if the first line. Else append.
        with open(f"./writefile{file_number}.csv", ("w" if current_line_no == 0 else "a")) as writefile:

            # check if the "headers" are appearing and if the current file has more than 1 line.
            #  Not sure if the header check is the best for your use case. Maybe regex is best here.
            if current_line_no != 0 and ("eno" in line and "ename" in line):
                file_number += 1        # increment to next file
                current_line_no = 0     # reset file number
                tmpline = line          # remember the "current line". This needs to be added to next file.
                continue                # continue to next line in readfile

            # if there is a templine from previous, add it to this as header.
            if tmpline is not None:
                writefile.write(tmpline)
                tmpline = None

            # write the line and increment to new line
            writefile.write(line)
            current_line_no += 1

I've tried to comment as best as possible. The code basically opens the files one by one as it loops through the lines of the readfile. When it reads the contents it checks if the current line is a "header". Here I simply checked if "eno" and "ename" are in the line, but there is probably a better approach for your use case. If the current line is a header, then you need to close the current file and open a new one. Hopefully this helps!
Comment: (You can probably speed this up by creating something like a `current_buffer` variable which dumps to file when a new header is encountered. That way you don't need to keep opening and closing files for every single line.)
Answer: I know you asked for Python, but there are some questions that just cry out for the power of AWK :)
awk '/eno,ename/{x="F"++i ".csv";}{print > x;}' input.csv

Answer: One way of doing it is to save the headers to a variable, and then when reading the file check if the current row matches the header. If it does, increment a counter that can be used to determine which file to write to.
import csv

HEADERS = next(csv.reader(open('data.csv')))
print(HEADERS)
with open('data.csv') as f:
    reader = csv.reader(f)

    file_name_counter = 0
    for row in reader:
        if row == HEADERS:
            file_name_counter += 1

        with open(f'data{file_name_counter}.csv', ('w' if row == HEADERS else "a"), newline="") as f:
            writer = csv.writer(f)
            writer.writerow(row)

NOTE: I believe the newline="" argument is necessary on Windows, as otherwise csv.writer() will add an extra new line between each entry.


Modified transport equation difficulties

Question: I got stuck on part of a question, and I have the feeling there's a simple approach that I'm not thinking of.  Here is my work so far:
Ultimately, we would like to solve the PDE

$$u_t+cu_x = u\tag{T}$$
  $$u(x,0) = f(x) \tag{IC}$$

With the substitution $u(x,t) = v(x - ct,t)$, we get the modified version

$$v_t = u = v(x-ct,t)$$
  $$v(x,0) = f(x)$$

I think that there should be a way of finding a general solution to that first equation
$$v_t = v(x-ct,t)$$
Certainly, $Ce^t$ would be a valid solution.  However, the general solution must somehow involve an undetermined function of $x$, and I'm not sure how to bring it in to here. My immediate thoughts were to try $\psi(x)e^t$ and $\psi(x-ct)e^t$, but the first never works, and the second will not work for an undetermined differentiable function $\psi$.  At this point, I feel as though I've run out of ideas.
Any help or hints are appreciated.
Answer: (I hope my notation is not too horrendous) We used the method of characteristics to solve this equation in my PDEs class.  The characteristic equations are given by, $$\frac{\partial{t}}{\partial\tau}=1,\quad\frac{\partial x}{\partial \tau}=c,\quad\text{and}\quad \frac{\partial u}{\partial \tau}=u $$
where $\tau$ is a parameter.  I get $t=\tau$, $x=c\tau+x(0)$, and $u=u(x(0),0)e^\tau$. (Here $x(0)$ is just my initial value when our parameter $\tau=0$.)  The initial conditions give
$$ u=f(x(0))e^t $$
Solving for $x(0)$ gives us that $u(x,t)=f(x-ct)e^t$, which is essentially what you had.  Taking partial derivatives, we see this solution satisfies our PDE.  Hope that helps!
Comment: I realized my mistake. I had suppressed the parameters of $v_t$, and that led me to believe I had $v_t(x,t) = v(x - ct,t)$ when I should have had $v_t(x-ct,t) = v(x-ct,t)$.  This leads me to the solution you have, which is correct.  It's also good to see an alternate method.  At any rate, thank you kindly for the quick response.
Comment: For Sure.  This was my second post ever on stack exchange, so I'm glad it helped! Cheers.
Comment: Welcome aboard then! Cheers.


How to use Cognos Analytics to define different aggregation functions(Ex: average, sum) for different columns?

Question: I want to build a report and suppose I have the following table in my report:
<code>2012 OCT 7547  697  0.08
     NOV 9570  373  0.04
     DEC 1879  107  0.05
</code>
I want to create a total row: for the first numeric column I want to calculate mean, for the second total and for the third sum. How can I do that?
I am using the 11 version of Cognos Analytics
Comment: We are using Cognos 10 so I want to confirm the terminology first. Are you building this report in report studio?
Comment: @AquaticallyChallengedFish yes, exactly
Answer: Report studio will add, automatically, summary objects to reports so that's there for free; the only question after that is the nature of the aggregation.
What's the source of the metadata that you're using?  Is it a package or module?   What's the aggregation which has been defined in the model?  Why can't you leverage what's all ready there?  If you look at the generated SQL, what aggregations are being done?
Total is sum aggregation so I'm not sure what you mean when you say you want one query item to aggregate as sum and another as total.  Could you explain that pls.
Answer:
Select the first numeric column.
On the context-sensitive toolbar, select the summarize tool (sigma) and click Average.
Select the second and third numeric columns.
On the context-sensitive toolbar, select the summarize tool and click Total.

Cognos will separate the averages and totals into different summary rows.  If you want them all in one row:

Unlock the report by clicking on the More button in the top right of the screen.
Select the label cell on the total summary row.
On the context-sensitive toolbar, click the Split Cell tool.
Select the average (first numeric column) and drag it to the total row.
(if you want to) Change the label on the total summary row.
Lock the report.
Select the average summary row and delete it.

You may want to find some basic Cognos report development training.  IBM and others have produced videos on this topic and posted them to YouTube.  There are also vendors (IBM partners?) who provide this training.  Or just contact your Cognos support staff in your IT division.


Replace all double spaces with single spaces in string

Question: I would like to reduce all spaces longer than a single space in a string to a single space.
foo(" 1   2    3     4                 5 ")
[1] " 1 2 3 4 5 "

Comment: possible duplicate of [How to remove extra white space between words inside a character vector using R?](http://stackoverflow.com/questions/19128327/how-to-remove-extra-white-space-between-words-inside-a-character-vector-using-r)
Comment: Good point. I did not see that.
Answer: That would work:
gsub(' +',' ',foo)

:)
(edited to take into account Zach's comment)
Comment: Suggest `"  +"` instead of `"  *"`.  It will do less unnecessary work.


Filter data.frame with all colums NA but keep when some are NA

Question: I want to remove rows from a data.frame where all cols are NA. But I'd like to keep rows that have some values NA.
I know how to do this with base R but I'm trying to figure out how to make it work with tidyverse. I'm trying the across operator.
library(tidyverse)

teste <- data.frame(a = c(1,NA,3, NA), b = c(NA, NA, 3, 4), c = c(1, NA, 3, 4))

teste
#>    a  b  c
#> 1  1 NA  1
#> 2 NA NA NA
#> 3  3  3  3
#> 4 NA  4  4
# I whant to remove rows where all values are NA
# that is, remove only line 2

# here I can get the lines with all values NA
teste %>%
  filter(across(a:c, is.na))
#>    a  b  c
#> 1 NA NA NA

# If I negate the filter, it does not work
# the last line (NA, 4, 4) is missing
teste %>%
  filter(!across(a:c, is.na))
#>   a  b c
#> 1 1 NA 1
#> 2 3  3 3

# This is what I'm expecting
# a  b  c
# 1 NA  1
# 3  3  3
# NA  4  4

# Using base I can do this with
teste[apply(teste, 1, function(x) sum(is.na(x))) < 3,]
#>    a  b c
#> 1  1 NA 1
#> 3  3  3 3
#> 4 NA  4 4

How can I do this using tidyverse?
Created on 2020-08-18 by the reprex package (v0.3.0)
Comment: Does this answer your question? [Remove rows with all or some NAs (missing values) in data.frame](https://stackoverflow.com/questions/4862178/remove-rows-with-all-or-some-nas-missing-values-in-data-frame)
Comment: It did help find a way to do it using Base R. But I had a hard time finding an answer using filter. Maybe I did not grasp all the information in those answers. Anyway, I already accepted an answer here, but ended up using R base in my code...
Answer: We can use base R
teste[rowSums(!is.na(teste)) >0,]
#   a  b c
#1  1 NA 1
#3  3  3 3
#4 NA  4 4

Or using apply and any
teste[apply(!is.na(teste), 1, any),]

which can be also used within filter
teste %>%
      filter(rowSums(!is.na(.)) >0)

Or using c_across from dplyr, we can directly remove the rows with all NA
library(dplyr)
teste %>%
    rowwise %>%
    filter(!all(is.na(c_across(everything()))))
# A tibble: 3 x 3
# Rowwise:
#      a     b     c
#  <dbl> <dbl> <dbl>
#1     1    NA     1
#2     3     3     3
#3    NA     4     4

NOTE: filter_all is getting deprecated
Comment: @NelsonGon If memory is not a constraint, then it should be fast.  Otherwise, for really big dataset, it depends on the number of columns, etc.  It may be slightly faster with `tidyft` if the input dataset is fst
Comment: I saw a similar question on Twitter and gave something similar to the `rowSums` solution. However, I've been wondering how fast this solution would be for very large datasets since it seems too "expensive" to check with `is.na` on the entire dataset first.
Answer: Previously in dplyr, you could use filter_all (for all columns)/filter_at (for specific columns) which had any_vars :
library(dplyr)

teste %>% filter_all(any_vars(!is.na(.)))

However, across does not have direct replacement of any_vars so you can use this with Reduce :
teste %>% filter(Reduce(`|`, across(.fns = Negate(is.na))))
#   a  b c
#1  1 NA 1
#2  3  3 3
#3 NA  4 4

Answer: Using data.table, you can produce the same outcome.
teste2 <- teste[-which(is.na(teste$a)&is.na(teste$b)&is.na(teste$c)),]


HP 8510p notebok overheating with ubuntu

Question: I've recently instaled ubuntu 12.10 on my notebook and noticed that it starts overheating after a few minutes of simple usage having only for example a browser opened or reading a pdf so nothing procesor intentsive.
I've tried also with xubuntu desctop thinking that it would be more lightweight, but with no success.
I have a core2duo intel porcesor and ati radeon 2600HD graphic card.
I've also tried to install the proprietary drivers for the graphic card but no success, when I install drivers and login the menu is gone in unity
Do I have any chanses to stop this overheating...any hints?
I'm pasting the sensors output :
Adapter: Virtual device
temp1:        +71.0°C  (crit = +105.0°C)
temp2:        +45.0°C  (crit = +105.0°C)
temp3:        +26.8°C  (crit = +105.0°C)
temp4:        +75.0°C  (crit = +110.0°C)
temp5:        +55.0°C  (crit = +256.0°C)
temp6:        +45.0°C  (crit = +105.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +49.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:       +47.0°C  (high = +100.0°C, crit = +100.0°C)

radeon-pci-0100
Adapter: PCI adapter
temp1:        +51.0°C

the temp1 and temp4 are problematic, temp4 sometimes goes as far as 100%
Anyway how can I find out what temp1 and tem4 are refered to? Is that a graphic card chip or something else?
Just hit the 100°C
acpitz-virtual-0
Adapter: Virtual device
temp1:        +75.0°C  (crit = +105.0°C)
temp2:        +46.0°C  (crit = +105.0°C)
temp3:        +27.0°C  (crit = +105.0°C)
temp4:       +100.0°C  (crit = +110.0°C)
temp5:        +55.0°C  (crit = +256.0°C)
temp6:        +45.0°C  (crit = +105.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +49.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:       +47.0°C  (high = +100.0°C, crit = +100.0°C)
radeon-pci-0100
Adapter: PCI adapter
temp1:        +56.0°C

Aditional info:

the fan is working on 100% when overheating occures
I've installed also WIN7 on the same notebook and there the problem is not occuring
the CPU is 99% idle when overheating occures so it is not the CPU
I've also updatet the BIOS to the latest image but does not help
Comment: The cpu is quite idle when overheating occures, the notebokk is already clened from dust. So I asume that it is some other chip that overheats, probbably the grapics card, but I'm not certainn of that, I should also point out that I have dual boot and WIN7 installed as an alternate system and in WIN7 the notebook is not overheating. There everything below 70°C
Comment: Thanks for the updated information. I still stand by my earlier statement: *A laptop with fans at full speed shall never overheat (100°C).* In no circumstance, this should be possible. I've seen this happening on my old ThinkPad T61 too and it appeared to be *way too much* thermal grease on the GPU chip to the heatsink. Re-applying it with a more sensible amount fixed the issue for me (together with proper fan control in the kernel).
Comment: @gertvdijk not sure that the new termal grase would hepl...in my opinion is some driver problem because on win7 it is working ok with no overheating
Comment: In a similar question with the same laptop [it was reported](http://askubuntu.com/questions/93824/how-do-i-cool-of-my-laptop#comment107488_93824) that driver version 11.2+ of the fglrx driver makes the laptop run a lot cooler. Still, a laptop should not reach 100°C at full power in normal conditions, no matter what kind of software/driver you use.
Comment: thnx for the info I've found a partial solution lowering the power profile to low more info here ... but it is rely an ugly work around

http://www.techytalk.info/ubuntu-open-source-ati-radeon-driver-power-usage-tweaks/
Answer: The most likely reason for the overheat is that the CPU is being driven at or close to 100% utilisation.
Fire up a copy of system monitor and look to see what your CPU utilisation is, if it's high as I suspect, then use the system monitor to look at running processes etc, see if you can determine which of those processes is the one most using the CPU.
If there's a clear leader then if possible terminate that process and see if your CPU cools down.
One thing to always remember about laptops is that most of them are passively cooled and / or only have relatively small fans, it may not be any software that your running thats causing it, it may just be the way your using it or sitting it on your knee for example.
I used to have a thinkpad that had a very small cooling aperture, and it only needed to be on my knee for less that a minute before the cooling system kicked into high gear due to getting too hot.
I don't know where in the world you are, but here in the UK we have a chain of shops called "poundland" who just recently have been selling USB laptop stands, these are a perspex stand about 1 inch high with a perforated deck and a fan in the middle with a USB plug on.  Plugging the USB plug into your laptop USB port powers the fan and blows cool air across the bottom giving it extra ability to keep cool.  There cheep and cheerful, but at £1 uk you can't go wrong.
UPDATE
After a little bit of research, it's also come to light that some model's of HP laptops have a problem with the BIOS, this problem prevents the BIOS from switching on the fans correctly using the power management facilities on the device, the good news is that a patch can be obtained from HP to rectify the issue, and like all patches can be downloaded from the HP site.
UPDATE 2
http://h30499.www3.hp.com/t5/Notebook-HP-ProBook-EliteBook/8510p-overheating/td-p/1029105
http://forum.notebookreview.com/hp-compaq/368280-my-8510ps-temps-rising.html
http://forum.notebookreview.com/hp-compaq/185730-hp-8510p-weird-crashes.html
There also seems to be a general conscious that the copper piping inside this model is badly designed and not up-to the job of removing the amount of heat they need to.
Comment: If you have an alternative route that the OP should investigate, then instead of picking fault with my answer, why not compliment it and add your own answer and your own spin on possible causes to the issue, let the OP decide for themselves instead of waiting to be told.  People like you or I that take time to answer on places like this have a duty to educate folks not just outright solve thier problems for them :-) *Rant Over* - Extends a hand to shake....
Comment: *"most likely reason for the overheat is that the CPU is being driven at or close to 100% utilisation"* No it's not. `coretemp` temperatures are under 50°C.
Comment: Temperatures under 50 degrees don't mean nothing... it's exactly what it says, a measure of Kinetic energy radiated into the outside atmosphere by Conductive means.  What your saying by that comment is basically, for the CPU to be driven at 100% it has to be at 100 degrees C temperature, or 1% = 1 degree, which is I'm sorry to say an insane idea.  I have a Raspberry Pi sat here on my desk, I can drive that at 10% utilisation, and hit 55 degrees.  My laptop on the other hand, I can drive easily at 75% utilisation and yet maintain a steady 40 degrees.
Comment: That's not what I was trying to say. All I'm saying here is that it is very wrong to point at the CPU to be the cause for overheating. It's almost the coolest part of the laptop! Clearly, *another part* is 100°C+.
Comment: ok fair enough, but if you read my comment again, you'll see that I'm mearly suggesting it as a possibility, I'm in no way saying this is your exact problem, and as is (or should be the way) on these stack exchange sites, other people should come along and put their own honest answers on too, and let the OP decide for his/her self which course of action to follow.  I don't ever claim to be right on these boards, all I ever offer is the benefit of the experience I have.
Comment: *"What your saying by that comment"* makes your own comment far from a suggestion. I was just pointing out what my view on it was, no flames intended. Your update is a completely (and very good!) answer to the question. Consider posting it as a separate one with a reference and I will upvote it as it sounds very credible.
Comment: tnx for the info, I'll look if there are some bios patches...about the cpu I'm not shure that it is the cause because is quite idle when overheating occures, I thinh that it is a graphic chard because I have one fan taht it is connected to tge CPU and to GPU by some cooling tubes and that fan is going crasy when overheating starts, so if cpu is quite low then in my opinion must be the graphic card that is boiling. But it is quite strange because I'm not doing anything graphic intensive.
Comment: @shawty I've installed the latest BIOS but it does not help, also the cpu is idle when this happens...it must be some driver issue ... I've also win7 ant there it si working ok
Comment: I don't know if it's a full / latest BIOS update, but I have it on good authority ( A senior systems consultant at Fujitsu in Australia ) that they purchased some 100 of this model laptop and had the same problem with the fans on all of them.  I can't say if this is 100% accurate, but I do trust my source in this case as they work very closely with HP.  This is not an uncommon problem it would appear, have added some links to my answer that may be of assistance.
Comment: @gertvdijk no flames intended. I had some mad Isreli guy snapping at my heels in this very group trying to belittle everything I was answering yesterday, he rattled me up the wrong way I guess I snapped when I saw your answer :-)


Problem in connecting wired network

Question: Operating System: Ubuntu 14.04 gnome version
Wired network shows connecting icon but actually not getting connected
Comment: What does ping -c 4 google.com and ping -c 4 184.108.40.206 tell you ?
Comment: On executing ping -c 4 google.com and ping -c 4 18.104.22.168, it shows ping: unknown host google.com and connect: Network is unreachable, respectively @serg
Comment: Try doing `sudo service network-manager restart` to restart network-manager and re-establish the connection. Also, try removing all the files in `/etc/NetworkManager/system-connections` and then reconnecting. You can do so by doing `sudo rm /etc/NetworkManager/system-connections/* && sudo service network-manager restart`
Comment: Still its not working. Although, the ethernet cable is connected, it shows disconnected icon @Serg
Answer: I would first check if the wired network is actually working correctly. Do you know if other people or machines are actually able to connect using a wired connection on the same network.
Second, I would check if the network adapter is functioning correctly. Is the same network adapter able to connect successfully on another network?
Thirdly, check if you are able to get an IP address via DHCP on the network. You can do this by running ifconfig from a terminal.
You may also need to confirm whether network policies are in place that may be limiting your ability to connect on the wired network.
Comment: 1,2,4 holds good. 3 ifconfig is not depicting any IP address. Only hardware is shown

Problem in connecting wired network