For the family, $f_\theta(x)=\frac{e^{-(x-\theta)}}{1+e^{-(x-\theta)})^2}$, compute the fisher information, is it an exponential family?

Question:
For the family, $f_\theta(x)=\frac{e^{-(x-\theta)}}{1+e^{-(x-\theta)})^2}$, compute the fisher information, is it an exponential family, $x\in \mathbb{R},\theta \in \mathbb{R}$?

I computed the fisher information as $I(\theta)=E[(\frac{\partial log f_\theta(x)}{\partial\theta})^2]$
$\frac{\partial}{\partial\theta}lnf_\theta(x)=\frac{\partial}{\partial\theta}\ln\frac{e^{-(x-\theta)}}{(1+e^{-(x-\theta)})^2}=\frac{\partial}{\partial\theta}[\ln e^{-(x-\theta)}-\ln(1+e^{-x_\theta)})^2]=1-2\frac{1}{1+e^{-(x-\theta)}}\cdot e^{-(x-\theta)}$
Then $(1-2\frac{1}{1+e^{-(x-\theta)}}\cdot e^{-(x-\theta)})^2=1-4\frac{1}{1+e^{-(x-\theta)}}\cdot e^{-(x-\theta)}+\frac{e^{-2(x-\theta)}}{(1+e^{-(x-\theta)})^2}$
Then $E(1-4\frac{1}{1+e^{-(x-\theta)}}\cdot e^{-(x-\theta)}+\frac{e^{-2(x-\theta)}}{(1+e^{-(x-\theta)})^2})=1-4e^\theta E(\frac{e^{-x}}{1+e^\theta e^{-x}})+e^{2\theta}E(\frac{e^{-2x}}{1+e^{-(x-\theta)})^2})$
$E(\frac{e^{-x}}{1+e^\theta e^{-x}})=E(\frac{1}{\frac{1}{e^{-x}}+e^{\theta}})=\int_\mathbb{R}\frac{e^{-(x-\theta)}}{1+e^{-(x-\theta)})^2}\cdot\frac{1}{\frac{1}{e^{-x}}+e^{\theta}} dx$
So my issue now is I don't feel I can compute this integral, so maybe I've made a mistake in computing this somewhere.
For showing whether it is or isn't an exponential family, I believe it is not, but I'm not sure how to prove something is not an exponential family, only how to show it is.
My definition of exponential family is:
if $f_\theta(x)=h(x)e^{\sum_{i=1}^k c_i(\theta)T_i(x)-d(\theta)}$ then $f_\theta(x)$ is a k-parameter exponential family.
Comment: Use the alternative formula $I(\theta)=-E_{\theta}\left[\frac{\partial^2}{\partial\theta^2}\ln f_{\theta}(X)\right]$.
Answer: It's good advice to switch to an alternative definition of Fisher's information if one of them takes you to a dead end to no avail.
Observe that
$$
\frac{d^2\ell}{d\theta^2} = -\frac{2e^{-(x-\theta)}}{(1+e^{-(x-\theta)})^2}.
$$
Therefore,
$$
\begin{align}
I(\theta) &= -E\left(\frac{d^2\ell}{d\theta^2}\right) = 2\int_{-\infty}^{-\infty}\frac{e^{-(x-\theta)}}{(1+e^{-(x-\theta)})^2}\frac{e^{-(x-\theta)}}{(1+e^{-(x-\theta)})^2}\,dx\\
&= 2\int_{-\infty}^{\infty}\frac{e^{-2(x-\theta)}}{(1+e^{-(x-\theta)})^4}\,dx
\end{align}.
$$
Consider the transformation $y = \frac{e^{-(x-\theta)}}{1+e^{-(x-\theta)}}$ whose Jacobian is $dx = \frac{1}{(y-1)y}\,dy$. Note that $y\to 0$ as $x\to\infty$ and $y\to 1$ as $x\to-\infty$. Therefore,
$$
\int_{-\infty}^{\infty}\frac{e^{-2(x-\theta)}}{(1+e^{-(x-\theta)})^4}\,dx = -\int_1^0 \frac{y^2(1-y)^2}{y(1-y)}\,dy=\int_0^1 y(1-y)\,dy = B(2,2),
$$
where $B(a,b)$ is the beta function. Using the relationship between the beta function and the gamma function, $B(2,2) = \frac{\Gamma(2)\Gamma(2)}{\Gamma(4)} = \frac{1}{6}$. Therefore, $I(\theta) = \frac{1}{3}$.
Now, does the logistic distribution in your question belong to an exponential family? No, because the density cannot be represented as $h(x)\exp\{\eta(\theta)T(x)-A(\theta) \}$. Observe that the density $e^{-x}\exp\left[-2\log\{1+\exp(-(x-\theta))\} + \theta \right]$ is impossible to be rewritten in terms of the product of $\eta(\theta)T(x)$.


Change Gateway doesn't work on Windows 7

Question: This PC was configured with 192.168.6.1. But I tried to change it to 192.168.6.51. Although route print showed the default gateway is 192.168.6.51, but the packets next hop is 192.168.6.1.
<code>IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
      0.0.0.0          0.0.0.0     192.168.6.51     192.168.6.50    261
    127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
    127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
  192.168.6.0    255.255.255.0         On-link      192.168.6.50    261
 192.168.6.50  255.255.255.255         On-link      192.168.6.50    261
192.168.6.255  255.255.255.255         On-link      192.168.6.50    261
    22.214.171.124        240.0.0.0         On-link         127.0.0.1    306
    126.96.36.199        240.0.0.0         On-link      192.168.6.50    261
255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
255.255.255.255  255.255.255.255         On-link      192.168.6.50    261
===========================================================================
Persistent Routes:
None
</code>
But when tried tracert 18.104.22.168, the next hop is still 192.168.6.1.
<code> Tracing route to 22.214.171.124 over a maximum of 30 hops

1    <1 ms    <1 ms    <1 ms  192.168.6.1
2     1 ms     4 ms    <1 ms  ^C
</code>
Comment: I believe Windows may cache the routing.  Have you rebooted?  Or maybe if you issue `netsh interface ip delete destinationcache`
Comment: Thanks for suggestion. I tired this already. It doesn't work. Any idea?
Answer: Try resetting the winsock catalog. This should reset the adapter and all the cachings.
<code>    netsh winsock reset
</code>
After this, you will need to restart the machine.
Comment: Do you have to drag up an old, low-quality question and give a very basic and generic answer?


how can i define a maintenance template within a custom module?

Question: i have done this within a module for defining custom templates when having status error
function custom_module_preprocess_region(&$vars) {

  $header = drupal_get_http_header('status');

  if( $vars['region'] == 'content' ) {
if ($header == '404 Not Found') {
  $vars['theme_hook_suggestions'][] = 'content__404';
}
if ($header == '403 Forbidden')  {
  $vars['theme_hook_suggestions'][] = 'content__403';
}
 }
 }

 function custom_module_theme() {
   return array(
'content__404' => array(
  'template' => 'region--content--404',
  'variables' => array('xxx' => null),
  'path' => drupal_get_path('module', 'custom_module').'/templates'
),
'content__403' => array(
  'template' => 'region--content--403',
  'variables' => array('xxx' => null),
  'path' => drupal_get_path('module', 'custom_module').'/templates'
),
'maintenance' => array(
  'template' => 'region--content--maintenance',
  'variables' => array('xxx' => null),
  'path' => drupal_get_path('module', 'custom_module').'/templates'
),
 );
 }

How can i implement it just the same to override the theme maintenance tpl ?
Comment: Is it for D7 or D8?
Comment: sorry i should have precised for D7
Answer: drupal_get_http_header() should be treated as deprecated.
See https://www.drupal.org/node/1969270#comment-7609337
I think your approach is good, but for a little more coverage of 404/403 pages we came up with a more extendable approach, also theres a bit more room for customization in the backend within the modules settings page.
We did this by using the customerror module in conjunction with a theme function and a few overriding template files.
https://www.drupal.org/project/customerror
After installing, add this to your template.php file's theme_preprocess_page function. Example;
function YOURTHEME_preprocess_page(&$variables) {

  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) && $alias_parts[0] == 'customerror') {
    if ($alias_parts[1] == '403') {
      $variables['theme_hook_suggestions'][] = 'page__forbidden';
    }
    if ($alias_parts[1] == '404') {
      $variables['theme_hook_suggestions'][] = 'page__not_found';
    }
  }

  <other code goes here>

}

Then in your templates folder add your custom templates (just like your page.tpl.php file);

page--forbidden.tpl.php
page--not-found.tpl.php

Clear your cache, hit one of those pages (you can test them by going to);

[yoursite]/customerror/403
[yoursite]/customerror/404

As for your maintenance page, all you need to do is create a
maintenance-page.tpl.php file and toss that in your templates folder.
Comment: i am trying to have all code contained in the module, for multisites purpose


Ending of Ballade in G Minor

Question:
Hi,
I'm currently working on Chopin's Ballade in G Minor and have come across a problem I can't work on. The two sets of scales shown below are meant to be played rapidly. However, whenever I try this, my right and left play out of sync and ends up sounding really muddy. I've tried playing slowly with a metronome but hasn't helped me reached the speed I want it to. Any suggestions?
Comment: The usual trick I apply is to let the left hand lead (which usually means it'll be louder than the right hand), since the left hand tends to be the underpracticed hand for scales, and causing the hands to go out of sync. Over time, the left hand can fade back to its normal loudness, while still performing that lead for a double scale.
Comment: Practice. That perhaps feels too simplistic, but we could use some more information from you if we were to suggest *how* you should practice. A few questions to start of with: can you get the correct speed with individual hands while sounding regularly (equal eights, accents in the right places)? Do you practice scales outside of this piece regularly? Can you identify more clearly at what point things go bad (first few notes, after one octave, certain hand positions/finger crossings). At what speeds can you still handle the scales comfortably? How long have you practiced this section?
Comment: Start slow and increase the speed *more slowly* than you tried. That sounds unhelpful, but I can assure you that the only way to make progress for this nasty run is to approach the final tempo so slowly that you *think* you're not making *any* progress.
Answer: Two things.
First, those scales need to run pretty quickly, it is true. Are you able to play any scales at, say, 144? Probably not. You have to work at them. And, all the while you're working on them, it often seems like you're not making any progress. But then one day you sit down and run one off, and it suddenly sounds a bit better than it did just the day before.
I suggest that you practice your G melodic minor scale, both in octaves and in tenths, four octaves. Make sure that you don't allow yourself to let the hands get uneven. Work on it very slowly (start with, say, one note per second or 60 on the metronome, and two octaves is ok to begin with), note by note, making sure that each hand hits at exactly the same time. As you get the evenness, the speeding up will happen naturally on its own.
If you aren't finding that to be the case, then it's most likely because you aren't being rigorous enough with yourself in paying attention to that evenness. Probably because you are letting your right hand tantalize you a bit, because, you know, it plays so much better than your left (if you're left-handed, then the opposite is true of course), and so is so much closer to what you want.
One of my teachers once told me that he spends three times as much time working on his left hand as he does with his right. Your right hand has to slow down and give your left hand a chance to keep up with it. Don't let yourself become impatient; a way to not make progress is to keep going over things wrong. If you do that, don't expect things to improve; you're just teaching your hands how to play things wrong. Then you have to un-teach them, and that's much tougher than teaching them right in the first place.
If you don't work out the problems with the evenness, they will magnify exponentially as you attempt to speed up the scale. So work on it.
The next thing is that if you can't play your scales evenly, you are having problems with most of the rest of the piece as well. Don't obsess over one detail or another and gimp your way through the "parts that you're putting off until later." If you're practicing in problems, you'll have to unlearn them. So be rigorous with your approach. Don't let details go.
Above all, be patient. And don't feel like a failure if you decide to put this aside for a while (you'll have improved your G melodic minor scale, after all) and work on some less difficult Chopin music. (Mazurkas!)  It's a way of breaking up problems into smaller bites. Every piece you learn well contains keys to mastering more difficult pieces.
p.s. In case you couldn't tell, I did all the things I'm telling you not to do, slopping my way through this very piece until nobody could stand to listen to me practice it any more.
Comment: Soap I think you've hit the nail in your own comment. As I always tell students: if you want to play fast, you must practice slow. If the foundation is there, speed increases pretty quickly. Two suggestions: do a 2-1 approach: two metronome clicks up, 1 back = 60, 66, 63, 69 etc. Max out at 7 +/- 2 up clicks a day and you'll begin to see consistent progress. Give it the time it needs. The funny thing about impatience is that it prevents you from doing things as quickly as you want to.
Comment: Yeah, my left hand tends to fall behind the right hand once I get to a certain speed. I don't have much trouble playing scales at around 88 speed but one it exceeds that, my hands start going at separate speed. (I noticed that many of Chopin's work contains these rapid scales)

A bad habit I've had for many years is impatience, as you stated above. Whenever I work on a new piece, I tend to rush the piece instead of practicing it slowly with a metronome. And whenever I do finish the piece I feel like there are parts and details lacking all because I didn't practice it slower.
Comment: Also if I come across a section where my technique lacks or I just can't simply play well, I end up panicking and just try to cover up somehow(usually with the sustain pedals)
Comment: Or, more briefly, KEEP practicing it slowly with the metronone. It WILL come right.
Answer: When I'm practising hard passages like this, I have a 'practice toolbox' which I find very useful. This includes:
Slow practice - as numerous others have said, preferably with a metronome. But slow practice alone will not help you get the speed up.
Rhythms - really surprised nobody mentioned this! Maybe triplets then a long note, short-short-long-long, dotted rhythm, whatever suits you and whatever fits. Again with a metronome if possible.
Staccato - playing the whole passage staccato works fine, some more creative (and probably more helpful) things are to do two staccato notes then two legato etc.
Every week, you might want to increase the speed a little, and gradually you will find it super easy to play!
Of course, you don't have to isolate all of these things- you can play staccato rhythms slowly and things like that. The reason that these techniques work is because they force your brain to subconsciously think a lot harder about the passage than it normally would when taking it at face value- it's like playing practice games! A change of 'mindset' might also be useful- instead of looking at the passage like it is, see it as a scale (which you might find less scary).
Really hope this helps!
Comment: Thanks for the tips. If I was to increase speed every week or every few days, how long should it take until I can play these passages fluently and at the correct speed?
Comment: I've been at it for around a week or two and I'm not seeing drastic improvements.
Comment: It depends how much you practice to be honest, and the quality of your practice. My teacher always taught me to be extremely disciplined, eg when Im practising and I make a mistake, don't just carry on but go back to a suitable place. Also, you shouldn't increase speed every few days or week.you should do it whenever you feel comfortable doing so, maybe record yourself, liste  to see if the notes are all smooth, even length etc.

Ending of Ballade in G Minor


How to delete images from our app?

Question: I am using certain bitmaps in my app which I am storing in the Drawable folder. When the user uses these bitmap in some kind, I want those bitmaps to be deleted. How shall I Implement this without using any kind of databases?
Edit:
I came to know that res/drawable is Read only. Then is there a technique to save the bitmaps anywhere else and then delete them. Can SQLite database be used for this purpose? If Yes, some code would be very helpful.
Answer: You can not delete images from Drawable folder. Because android application apk file is read only, so from any directory of project structure of .apk file you are only able read available files but can not delete or modify these files.
Comment: Is there other way to save these bitmaps anywhere and then delete them? Can SQLite be used to do this and how?
Comment: @coder12345 - The only way is, you have to download these Bitmaps from your server to your application on application installation, Store in application's internal storage (storage options may be various) and then delete when not useful. This is the only way. But from application apk file directory you can't.
Comment: This means that if I have some images preloaded in my app , I cannot delete them.Am I Right? btw thanks!
Comment: Yes, You are right, Only if you are going to update your application version. (But this apply to all application weather they used your bitmaps or not, so not works in your case)
Answer: The Drawable folder is a Resource of your application. I can't think of any situation where you'll ever need to remove parts of your application, unless you are upgrading versions, in which case you remove and add new stuff yourself and then release some new version of your app. Therefore, your apk file is read only.
If you need to handle files in your application, you have some storage options you could take a look:
http://developer.android.com/guide/topics/data/data-storage.html

How to delete images from our app?


Priority Queue cannot be applied to given types

Question: I am new with working with priority queues and have formatted this code wrong, and I want to have my priority be a straight line distance to a city however I don't beleive I passed this information to the queue correctly.  Looking at the API I need to set the SLD as a the comparator

public PriorityQueue(int initialCapacity, Comparator comparator)
      Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.

but this isn't clear to me.
public static void GreedySearchMap(map Romania) {
    boolean done = false;

    city current;

    int numsteps = 10;
    int cursteps;
    int choice;
    int numconnections;
    int totaldist;

    cursteps = 0;
    current = Romania.Arad;
    totaldist = 0;

    /*create queue*/
    PriorityQueue<city> q = new PriorityQueue<city>(city city,int SLD);
    q.offer(current);
    current.visited = true;

    while (!done) {
        System.out.printf("Step %d, In %s, Distance\t%d\n", cursteps,
                current.getname(), totaldist);

        if (current.getname() == "Bucharest")
            done = true;
        else {

            current = q.poll();
            cursteps++;
            numconnections = current.getconnections();

            for (int i = 0; i < numconnections; i++) {
                choice = i;
                if (current.getcity(choice).visited == false) {
                    //totaldist += current.getdist(choice);
                    q.offer(current.getcity(choice), current.getSLD());
                    current.visited = true;
                }
            }
        }
    }

    System.out.printf("-----------------------\n");
}

My error is:
P:\csci395\hw4>javac GS.java
GS.java:85: error: method offer in class PriorityQueue<E> cannot be applied to g
iven types;
                                                            q.offer(current.
getcity(choice), current.getSLD());
                                                             ^
  required: city
  found: city,int
  reason: actual and formal argument lists differ in length
  where E is a type-variable:
    E extends Object declared in class PriorityQueue
 1 error

Comment: `if (current.getname() == "Bucharest")` Don't compare Strings with '=='. Use `.equals()` instead. Best practice is using it like this: `"stringLiteral".equals(stringVariable)` because you can avoid having a NullPointerException.
Comment: `city city,int SLD` is how parameters are declared, while `new PriorityQueue(city city,int SLD)` is constructor invocation (not definition). It should be `new PriorityQueue(someInteger, anInstanceOfCaparator)`. The argurments `someInteger, anInstanceOfCaparator` must be of types as required by the constructor signature.
Answer: The SLD is not the Comparator, it is just the thing being compared.
You need to create a class that does the actual comparison, and submit that:
new Comparator<city>() {
    @Override
    public int compare(city city1, city city2) {
        return city1.getSLD() - city2.getSLD();
    }
};

Read up on java.util.Comparator to get more acquainted.

Edit -

This is just one error, though.  The error you're getting from compilation, as described in the output from the compiler, is due to the fact that you're using the wrong arguments for the offer() method of PriorityQueue.  Only a city should be passed:  The SLD will be handled by the code of your Comparator instance.
Answer: First of all, give classes a capital name. 'city city' could generate compiler errors.
Secondly, your error message tells you what is wrong.
You should give a Comparator to your PriorityQueue. An int is not even a class object, it's of a primitive type. Look up Java Comparators (java.lang.Comparator) for more information.


how can I put an edit button in UITable at the end of a cell?

Question: I want to put a edit button(icon), as most application has in the cell where the value exists???
I want as below output,
Hotel Royal     >
Hotel Taj       >

shows the button or icon,
  how can I do it ???

if you don't understand my question, you may ask again .....
Answer: If you are asking for the > you see at the cells, these are accessoryViews.
You can get the standard accessory views by setting the accessoryType property of the cell
for  you use
cell.accessoryType = UITableViewCellAccessoryCheckmark;

for
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

and for
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

if you use the DetailDisclosure button you can get the taps on it with the tableview delegate method - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
Comment: Is there any size option, because when when it is in "cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
", then hard to click at exact position as compared to "cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;"
Comment: no, if you want a different size you have to create your own view and set the accessoryView of the cell.


prove that the inner product of path and velocity is zero

Question: let $I \subseteq \mathbb{R}$ be an open interval.
A function $\gamma : I \rightarrow \mathbb{R}^m $ is called a path and we write $\gamma (t)=(\gamma^{1}(t),\ldots,\gamma^{m}(t)) \in \mathbb{R}^m$.
If all m components are differentiable functions from $I \ \mbox{to} \ \mathbb{R}^m$,then the path is a differentiable path. Then for every $t \in I$, we consider $\gamma'(t)=((\gamma^{1})'(t),\ldots,(\gamma^{m})'(t)) \in \mathbb{R}^m$ which is called the velocity vector of $\gamma$ at t.
Question: if $\gamma:I \rightarrow \mathbb{R}^m$ is a differentiable path and $||\gamma(t)||=1, \ \forall t \in I$. We fix a point $t_0 \in I$ and denote $\gamma(t_0):=\vec{a},\gamma'(t_0):=\vec{q}$ Prove that $$<\vec{a},\vec{q}>=0$$
My method is to use $0\leq |<\vec{a},\vec{q}>| \leq ||\vec{a}|| ||\vec{q}||=||\vec{q}||$, then by squeeze theorem, we can have the inner product equals zero. However, as you see, my method does not work.
Comment: In general, the inner product of a path and its velocity is nonzero.  The extra conditions are key to proving this fact.
Answer: Hint Differentiate the function $t \mapsto \langle \gamma(t), \gamma(t) \rangle$.
Comment: Additional hint: the inner product is a dot product is a *PRODUCT*, so there's a product rule.
Comment: the hints given by you two are very useful , now i know what to do. Thank you!
Comment: You're welcome, I'm glad you found it helpful.


what is the best approach to copy /var content

Question: we have linux redhar 7
we want to keep the /var on other volume
so the plan is to:
<code>mkdir /var_copy
cp -rp /var/* /var_copy
umount /dev/mapper/vg-a-var /var
rm -rf /var
mkdir /var
mount /dev/mapper/vg-b-var /var
cp -rp /var_copy/* /var
</code>
so my question is
is it good approach to use cp -rp in order to copy /var content ?
or maybe because /var include simbolic link or hard link need to use other approach ? as cp -a or other ?
Answer: Instead of cp I suggest
rsync -aqxP /var/* /var_copy
...but your plan will break many things (rm -rf /var "under" a running system).
Better to

copy things
modify /etc/fstab
reboot

... as described here (and in many places): https://linuxconfig.org/how-to-move-var-directory-to-another-partition
Answer: One option is to only put some of the contents of /var on another volume. Shut down any affected services, copy the content over, and mount your new /var/lib/whatever/
Not everything will be moved over. Less risky because you are not changing other dynamic data like /var/log/ /var/run/ /var/spool/
If you ever rebuild the host for this service, then it is easy to split out  /var/ from the beginning.
(Note that once again, the "best" solution depends on your requirements.)


Every interval $I \subset \mathbb{R}$ is connected. [Proof clarification]

Question: I struggled to understand a part of the following proof.
Topological Proof that every Interval $I \subset \mathbb{R}$ is connected

Definition: A topological space is connected if, and only if, it cannot be divided in two
  nonempty, open and disjoint subsets, or, similarly, if the empty set and the whole set are the
  only subsets that are open and closed at the same time.

Proof. Suppose $I = A \cup B$ and $A \cap B = \emptyset$, $A$ and $B$ are both non-empty and open in the subspace-topology of $I \subset \mathbb{R}$. Choose $a\in A$ and $b\in B$ and suppose $a < b$. Let $s := \mathrm{inf}\{ x \in B ~|~ a < x \}$. Then in every neighborhood of $s$ there are points of $B$ (because of the definition of the infimum), but also of $A$, then if not $s = a$, then $a < s$ and the open interval $(a,s)$ lies entirely in $A$. And so $s$ cannot be an inner point of $A$ nor $B$, but this is a contradiction to the property that both $A$ and $B$ be open and $s \in A \cup B$.

My Problems
I am struggled with the bold parts. Probably because I'm more familiar with metric spaces than with topological spaces. I know that $\forall \epsilon>0, \exists y\in B:s+\epsilon>y$ and this implies that every open ball $\beta (s,\epsilon)$ contains a point of $B$. Furthermore, if $a=s\in A$ clearly $\beta (s,\epsilon)$ contains a point of $A$, otherwise, if $a<s$ then $(a,s)\subset A$ which also means that $\beta (s,\epsilon)$ contain a point of $A$. If this argument is correct, then my problem turns out to be the translation of these ideas of open balls and distances to the topological framework. I have the intuition that he is trying to show that $s$ is a boundary point of $B$ in $I$. As $A$ and $B$ separates $I$, $B^c=A$. So, $s$ can never be (an interior point) either in $A$ or in $B$.
I'm trying to furnish a proof in the context of a topological space. Can someone clarify my doubts?
Thanks in advance!
Answer: The first two bolded statements are less about using ideas from abstract topological spaces and more about using the definition of infimum, properties of real intervals and manipulating inequalities:
In what follows let us denote $B_a = \{r \in B\ :\ a < r\}$.

Then in every neighborhood of $s$ there are points of $B$ (because of the definition of the infimum), ...

Suppose $(p, q)$ is a basic neighborhood of $s$ in $\mathbb{R}$; so $ p < s < q$. Now since $s$ is the largest lower bound of $B_a$ and $q$ is larger than $s$, $q$ cannot be a lower bound of $B_a$.
So there must be a point $x$ of $B_a$ (and thus of $B$) such that $x < q$. Also since $s \leq x$ by the lower bound property of $s$, we have $p < s \leq x < q$ i.e. $x \in (p, q)$. Thus every basic neighborhood $(p, q) \cap I$ of $s$ in $I$ with the subspace topology, still contains that point $x$ of $B$ and we are done.

... but also of $A$, then if not $s = a$, then $a < s$ and the open interval $(a,s)$ lies entirely in $A$.

Again, consider our neighborhood $(p, q)$ of $s$ from earlier. If $s = a$, we are done because then $s$ is a common element of $A$ and the neighborhood $(p, q) \cap I$ of $s$ as required.
Otherwise, if $s \neq a$, then $a < s$. Again this is because of the largest lower bound property of $s$. $a$ is a lower bound on $B_a$ by definition. So since $s$ is the largest lower bound of $B_a$, $a \leq s$. Along with $s \neq a$ this implies $a < s$.
Now analyze the number $$x = \frac{\max(a, p) + s}{2}$$ Since both $p < s$ and $a < s$ in this case, we have $a, p \leq \max(a, p) < s$. So $p < x < s$ which implies $x \in (p, q)$. And $a < x < s \leq b$ which implies $x \in I$ because $I$ is an interval. Finally as $s$ is a lower bound on $B_a = \{r \in B\ :\ a < r\}$, any real $r$ which is less than $s$ but still $a < r$ cannot be in $B$. So $a < x < s$ implies $x \not\in B$. And this gives $x \in A$ as $A$ and $B$ partition $I$.

... And so $s$ cannot be an inner point of $A$ nor $B$, ...

I understand why this compact statement might lead you to think of $s$ being a boundary point of either $A$ or $B$. That is certainly a correct intuition which can be used to complete the proof. But the direct intention of this statement was much simpler: it was intending to derive a contradiction by showing that either $A$ is not open or $B$ is not open like so:
Note that $a \leq s \leq b$ which gives $s \in I = A \cup B$ as $I$ is an interval. Now:

if $s \in A$, then by definition of $A$ being open, there is a basic neighborhood $U = (p, q) \cap I$ of $s$ entirely contained in $A$. So since $A$ is disjoint from $B$, $U$ cannot contain any point of $B$. But this contradicts what we just showed above: every such $U$ contains a point of $A$ and a point of $B$.
and if $s \in B$, we get a completely analogous contradiction.
Answer: 1st question.  Let D = { x in B : a < x }.
Let U be a nhood of s = inf D.
Thus some u,v with s in (u,v) subset U.
If not some x in D with x < v, then for all x in D, v <= x.
As that contradicts s = inf D, exists x in D with s <= x < v.
Consequently that x which is in B, is in (u,v), thus in U.
2nd question using notation from above.
If U $\cap$ A is empty, then for all x in A, x <= u or v <= x.
Thus (u,v) subset B.
As a <= u, exists x in (u,s) $\cap$ D, a contradiction.
Thus U $\cap$ A is not empty.
Finally, either s in A or s in B.
If s in A, then as A is a nhood of s,
points of B are in A, a no no.
If s in B, then as B is a nhood of s,
points of A are in B, a no no.
Answer: ``($\dots$) but also $A$ ($\dots$)
Otherwise we would have $a<s-\epsilon <s\leq b'$ (some $b'\in B$ and $\epsilon >0)$. So $s-\epsilon$ would be in $B$ (because $a\in I$ and $b'\in I$ $\implies$ $[a,b']\in I$ by definition of interval ) and greater than $a$ but smaller than the infimum s (last part contradicting definition of infimum).
Your reasoning is good up to ``otherwise, if < then (,)⊂" which is not clear to me.
The proof aims to show $A\cap B\neq\emptyset$ (contradiction arrises from finding a point in both sets here).


Do notation for monad in function returning a different type

Question: Is there a way to write do notation for a monad in a function which the return type isn't of said monad?
I have a main function doing most of the logic of the code, supplemented by another function which does some calculations for it in the middle. The supplementary function might fail, which is why it is returning a Maybe value. I'm looking to use the do notation for the returned values in the main function. Giving a generic example:
-- does some computation to two Ints which might fail
compute :: Int -> Int -> Maybe Int

-- actual logic
main :: Int -> Int -> Int
main x y = do
  first <- compute x y
  second <- compute (x+2) (y+2)
  third <- compute (x+4) (y+4)
  -- does some Int calculation to first, second and third

What I intend is for first, second, and third to have the actual Int values, taken out of the Maybe context, but doing the way above makes Haskell complain about not being able to match types of Maybe Int with Int.
Is there a way to do this? Or am I heading towards the wrong direction?
Pardon me if some terminology is wrongly used, I'm new to Haskell and still trying to wrap my head around everything.
EDIT
main has to return an Int, without being wrapped in Maybe, as there is another part of the code using the result of mainas Int. The results of a single compute might fail, but they should collectively pass (i.e. at least one would pass) in main, and what I'm looking for is a way to use do notation to take them out of Maybe, do some simple Int calculations to them (e.g. possibly treating any Nothing returned as 0), and return the final value as just Int.
Comment: but the idea of a `Monad Maybe` is to see `Maybe`s as "potentially failing" computations. So here you make a "chain" of potentially failing computations, and return `Just result` in case it succeeds, and `Nothing` otherwise. If you are sure `compute` will always return an `Just _`, then why does it have the signature `Int -> Int -> Maybe Int`?
Comment: The point is that these calculations should result in a `Maybe` as well, or if not, you can use a `return`.
Comment: Not sure what you're referring to, `compute` or `main`? Either way, `compute` already returns a `Maybe` value, while `main` is intended to definitely return an `Int`, hence no `Maybe`. In other words, one of the calculations in `main` might fail, but at least one should pass which guarantees that `main` has an `Int` return value.
Answer: Well the signature is in essence wrong. The result should be a Maybe Int:
main :: Int -> Int -> Maybe Int
main x y = do
  first <- compute x y
  second <- compute (x+2) (y+2)
  third <- compute (x+4) (y+4)
  return (first + second + third)
For example here we return (first + second + third), and the return will wrap these in a Just data constructor.
This is because your do block, implicitly uses the >>= of the Monad Maybe, which is defined as:
instance Monad Maybe where
    Nothing >>=_ = Nothing
    (Just x) >>= f = f x
    return = Just

So that means that it will indeed "unpack" values out of a Just data constructor, but in case a Nothing comes out of it, then this means that the result of the entire do block will be Nothing.
This is more or less the convenience the Monad Maybe offers: you can make computations as a chain of succesful actions, and in case one of these fails, the result will be Nothing, otherwise it will be Just result.
You can thus not at the end return an Int instead of a Maybe Int, since it is definitely possible - from the perspective of the types - that one or more computations can return a Nothing.
You can however "post" process the result of the do block, if you for example add a "default" value that will be used in case one of the computations is Nothing, like:
import Data.Maybe(fromMaybe)

main :: Int -> Int -> Int
main x y = fromMaybe 0 $ do
  first <- compute x y
  second <- compute (x+2) (y+2)
  third <- compute (x+4) (y+4)
  return (first + second + third)
Here in case the do-block thus returns a Nothing, we replace it with 0 (you can of course add another value in the fromMaybe :: a -> Maybe a -> a as a value in case the computation "fails").
If you want to return the first element in a list of Maybes that is Just, then you can use asum :: (Foldable t, Alternative f) => t (f a) -> f a, so then you can write your main like:
-- first non-failing computation

import Data.Foldable(asum)
import Data.Maybe(fromMaybe)

main :: Int -> Int -> Int
main x y = fromMaybe 0 $ asum [
    compute x y
    compute (x+2) (y+2)
    compute (x+4) (y+4)
]
Note that the asum can still contain only Nothings, so you still need to do some post-processing.
Comment: Thanks, your comment that refers to it as a chain of successful actions made it clearer to me, and I realize I actually am going in the wrong direction. What I intend is not for it to be a chain of actions, but a series of computations (which any might fail, but one is guaranteed to pass), and returning the first out of the series that passed. In essence, what `main` is doing is abstracting away the possible failures and choosing the first that succeeds, so that a definite `Int` value can be used elsewhere when it calls `main`. Is there a way to do this?
Comment: @lookarpthestars: you could use `asum` for that, like `asum [compute x y, compute (x+2) (y+2)]`, which will return the first `Just` in the list, but this is still a `Maybe`, since it is possible that *all* computations fail.
Comment: See: http://hackage.haskell.org/package/base-188.8.131.52/docs/Data-Foldable.html#v:asum
Comment: Sweet, this comment along with the part you added after the edit gives me something to work from. Appreciate the concise answer.
Comment: @lookarpthestars to your first comment, *no*,  main is *not* "choosing the first that succeeds". only if all three computations succeed it returns a Just (with the sum of three results). otherwise it returns Nothing. so it tries to run all of them (one after another, but *all* of them) and then combine all the results.
Answer: Willem's answer is basically perfect, but just to really drive the point home, let's think about what would happen if you could write something that allows you to return an int.
So you have the main function with type Int -> Int -> Int, let's assume an implementation of your compute function as follows:
compute :: Int -> Int -> Maybe Int
compute a 0 = Nothing
compute a b = Just (a `div` b)

Now this is basically a safe version of the integer division function div :: Int -> Int -> Int that returns a Nothing if the divisor is 0.
If you could write a main function as you like that returns an Int, you'd be able to write the following:
unsafe :: Int
unsafe = main 10 (-2)

This would make the second <- compute ... fail and return a Nothing but now you have to interpret your Nothing as a number which is not good. It defeats the whole purpose of using Maybe monad which captures failure safely. You can, of course, give a default value to Nothing as Willem described, but that's not always appropriate.
More generally, when you're inside a do block you should just think inside "the box" that is the monad and don't try to escape. In some cases like Maybe you might be able to do unMaybe with something like fromMaybe or maybe functions, but not in general.
Answer: I have two interpretations of your question, so to answer both of them:
Sum the Maybe Int values that are Just n to get an Int
To sum Maybe Ints while throwing out Nothing values, you can use sum with Data.Maybe.catMaybes :: [Maybe a] -> [a] to throw out Nothing values from a list:
sum . catMaybes $ [compute x y, compute (x+2) (y+2), compute (x+4) (y+4)]

Get the first Maybe Int value that's Just n as an Int
To get the first non-Nothing value, you can use catMaybes combined with listToMaybe :: [a] -> Maybe a to get Just the first value if there is one or Nothing if there isn't and fromMaybe :: a -> Maybe a -> a to convert Nothing to a default value:
fromMaybe 0 . listToMaybe . catMaybes $ [compute x y, compute (x+2) (y+2), compute (x+4) (y+4)]

If you're guaranteed to have at least one succeed, use head instead:
head . catMaybes $ [compute x y, compute (x+2) (y+2), compute (x+4) (y+4)]


How does neural network training work, if there are A HUGE number of points that not differentiable?

Question: When I first saw ReLu function, I would not guess it will work in neural network because there is a point that is not differentiable. But it seems works very well on modern neural network.
My question is that, if we have a neural network with ReLu everywhere, then there are HUGE number of points that is not differentiable, then how to update the weights when we do not have the gradient at those points?
Comment: A finite number of points out of a uncountably infinite number doesn't seem huge to me
Comment: @kbrose the number of points which can be represented in floating point arithmetics is finite. It's true that the non-differentiability of ReLU is not a practical concern, but the reason is a bit different.
Comment: If "It's true that the non-differentiability of ReLU is not a practical concern, but the reason is a bit different" then I don't think I understand what is being said. I thought the question was asking about the practicalities of updating the weights via gradient descent when there are points where the gradient is not well defined.
Comment: @kbrose I think you understood the OP's question correctly (though his opinion would be more than welcome). The point is that the set of possible values for the weights of a NN **in practice** is finite, thus you can't use the finiteness of non-differentiable points to imply trainability of ReLU-based NNs.
Answer: The simple and perhaps unsatisfying answer is that we arbitrarily choose a gradient at 0.
Typically deep learning libraries will choose to have a gradient of 0. We can see this using the python libraries of Keras (with tensorflow backend) and numpy:
import keras
import keras.backend as K
import numpy as np

# Define simple model with only ReLU activation.
inp = keras.layers.Input([1])
x = keras.layers.Activation('relu')(inp)
m = keras.models.Model(inp, x)
m.compile(loss='mse', optimizer='sgd')

# get the gradients of the input with respect to the loss.
# This gradient is the gradient through the ReLU activation.
gradients = m.optimizer.get_gradients(m.total_loss, inp)

# create a function we can use to retrieve the gradient
input_tensors = m.inputs + m.sample_weights + m.targets + [K.learning_phase()]
get_gradients = K.function(inputs=input_tensors, outputs=gradients)

# Let's see the gradient of ReLU when passing in [-1, 0, 1, 2]
# as the input, with a target value of always 1
data_input = np.array([[-1.0, 0.0, 1.0, 2.0]]).T
sample_weights = [1.0] * 4 # just scales the gradient
target = np.ones([4, 1]) # The target is 1.0
training_phase = 1 # doesn't effect anything in this example
inputs = [data_input, sample_weights, target, training_phase]
grads = get_gradients(inputs)

X = data_input.flatten()
G = grads[0].flatten()
Y = np.array([1] * len(X))
print('\n'.join(['x = {:+.2f}, loss = {:+.2f}, (∂ loss)/(∂ x) = {:+.8f}'.format(*x)
                 for x in zip(X, (Y - X) ** 2.0, G)]))

This prints the following gradients:
x = -1.00, loss = +4.00, (∂ loss)/(∂ x) = -0.00000000
x = +0.00, loss = +1.00, (∂ loss)/(∂ x) = -0.00000000
x = +1.00, loss = +0.00, (∂ loss)/(∂ x) = +0.00000000
x = +2.00, loss = +1.00, (∂ loss)/(∂ x) = +0.50000000


How can I fix a pager limited to 2 pages?

Question: The pager on the home page of my website is limited to 2 pages, ie the paging links are only for page 1 and 2 and both next and last point to page 2, but there are a lot more pages than that.
Is there some setting which controls this?
Answer: You can set items per page for the Home page at Configuration/System/Site information/FRONT PAGE as shown in following image:

And you can check also how many nodes you have promoted to the frontpage  at Admin/Content. So these two settings will allow you set all this. Hope this will work.
Additional:
If you want more settings for the FrontPage, you can go to Admin/Structure/Views/ and you can see a view named FrontPage, that is by default disabled. But you can enable. And that view works as a FrontPage. So in views setting you can set as you want.
Comment: I do not have that. But you can just find whether there is 30 or more that 30 items which has the status of promoted to front-page or not. You can go to `Admin/Find content`, there under section of `Show only items where` filter it for `promoted` content. and then you can simply count whether  the filtered content is more that 30 or not. If more that 30, 30 items it should so on the front-page. So, this way you can check whether your site has at-least 30 promoted  node or not. If there is only 20, then whether if you set 25 or 30, it will show 20 only.
Comment: When I check the Front Page settings on my system the dropdown for selecting the number of posts goes to a maximum of 30, but although I have set it to 30 it still displays a maximum of 20
Comment: @vfclists I did check, ideally it should not show the different number of items than what it was set. I should not mention but please check the total number of nodes you have created and how much are set for `published to front-page`. and please also check whether you have enabled the views `FrontPage` and its pager.
Comment: Thanks. Is there a way for calculating how many nodes are set for `published to front-page`?
Comment: Using the frontpage view worked. For some reason the settings used on the Site Information page do not work properly


Trying to parse a file that looks partically hex encoded

Question: I'm trying to parse a file that looks sort of hex encoded but mostly not. I contacted support for the vendor who created the file and they said that they it can be parsed using "an 0x116 offset"
What is a 0x116 offset?
It took me 2 weeks to get an answer from the vendor on my first question, so I wanted to see if someone here could help me make sense of! Thank you!
Answer: "0x116 offset" means nothing. It could be a value that needs to be added to words or subtracted to remove some naive encoding, or anything else for that matter.
Could you post a part of the file? Is it binary or text? Could you define "mostly not"?
What vendor/software package/device does this file come from?


Splitting up bracket terms

Question: I found a statement saying: Let $\circledast $ be an associative binary operation on a set $\mathbb{X}$. A bracket term of length n, consisting of n elements $a_1, ..., a_n$ and arbitrary brackets, e.g. $K_4 = a_1 \circledast (a_2 \circledast a_3) \circledast a_4$, can be written as $K_n= (...(a_1 \circledast a_2)\circledast a_3) \circledast ...) \circledast a_{n-1})\circledast a_n$.
In other words: You can leave out the brackets.
Induction hypothesis: $K_k = (...(a_1 \circledast a_2)\circledast a_3) \circledast ...) \circledast a_{k-1})\circledast a_k $ for every bracket term of length $k, 3\leq k\leq n$.
The proof is simple, but in the induction step it makes use of the assumption that there are always $l, m \in \mathbb{N} \backslash \{0\}$ so that $l+m=n+1$ and $K_{n+1} = K_l \circledast K_m$
To my mind, this means that you can always split up a bracket expression at a certain position l (from left) or m (from right). Is this just a trivial fact or can/must this be further explained?
Edit: I have no problems with understanding the proof for the actual statement, but what's the reason for being able to split up arbitrary bracket terms?
Thanks in advance.
Comment: I left parts of the proof there just for understanding where the problem comes from.
Answer: Yes. That is what is usually called "strong induction," prove $p(n + 1)$ using $p(1)$ up to $p(n)$ true as the induction step.
As an aside, I'd try to get another text (at least as a complement). This looks like written for maximal pedantry, not clarity of understanding.
Comment: It's clear to me that you use p(1) up to p(n) for induction. I'm just concerned with getting those l,m. So my question is: Why can you split up arbitrary bracket terms?

Splitting up bracket terms


django manage.py settings default

Question: I have a settings.py file and a dev_settings.py file that I use to override some values for dev purposes.  Everytime I run the ./manage.py command, I have to specify --settings=whatever.local_settings.  This becomes very tedious to do every time and I am trying to find a way to force manage.py to load my dev_settings.py file every by default so that I don't have to type that long argument every time I want to run a command.
I have tried setting DJANGO_SETTINGS_MODULE, however, it appears that manage.py overrides this option.
Is it possible to make this happen or am I doomed to always specify that argument?
Answer: manage.py sets path to settings for you, that's why it's ignoring DJANGO_SETTINGS_MODULE (it's basically just script that wraps around django-admin.py).
There are 2 easy ways to fix your problem:

set DJANGO_SETTINGS_MODULE and use django-admin.py to run all commands instead of manage.py. This is even better if you use vitualenv.
copy manage.py and name it local.py (that's the name in my case) and rename all settings mentions to dev_settings.

For example:
#!/usr/bin/env python
from django.core.management import execute_manager
import imp

try:
    import settings_local
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings_local.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(settings_local)

You can run all commands by ./local.py now.
Comment: I went the django-admin.py route!  I didn't even realize you could do that.  I for some reason thought django-admin.py was just for creating new projects.  Silly me...
Answer: The way this is typically done is you have settings.py with all settings that are common between environments (things like INSTALLED_APPS, etc.). Then, you have something like settings_local.py, that defines settings particular to the environment in context. You then import settings_local.py in settings.py.
# settings.py

from settings_local import *

settings.py gets added to your source code repository, but settings_local.py does not. (However, you would normally add something like settings_local.py.example to the repo.)
When you first move your app over to production, for example, you pull down the code base from your repo. You then copy settings_local.py.example to settings_local.py and make any necessary environment specific changes.
You then have separate settings_local.py files in each environment, and it all just works.
Comment: I think @intargc is playing around with different technique (http://toastdriven.com/blog/2010/jan/05/better-local-settings/). It's actually easier to extend settings this way.
Comment: I'm not sure if it's really equal. When I tried to play around with extending (not overriding) of variables using this technique, it just refused to work. That was some time ago tho. I use the second one since then and it works well for me (simplifying it by creating new manage.py as described in my answer).
Comment: Well, his complaint is the downside to that approach. I don't necessarily disagree with the logic of that approach, but it's mostly semantic, and comes with the cost of having to constant specify the settings file to use. All things being equal, simpler is better, so I say the traditional approach of importing the local settings at the end is the superior.
Comment: Oddly enough, we had it this way and it worked great. However, we had a training session with Jacob Kaplan-Moss and he recommended that this way be avoided for a few reasons.  So we all decided to heed his advice and go the route we're doing now.
Comment: Well, I guess I can't argue with the Jacob ;), but in typical fashion the Django devs imposed a best practice and didn't go so far as to actually make it easy to follow. In my opinion, if it should be the practice to follow, the core team should have worked in a way to support it out of the box rather than requiring people to do something like modify manage.py ``.
Comment: I actually agree with you very much.  I find it to be a terrible idea personally, but he his reasons convinced some other devs on my team to go that route so now I'm stuck with this.  Problem was that when we had it the way you suggested, it worked just fine!
Answer: You can make a bash alias by adding these lines to your .bash_profile file:
mymanage()
{
python manage.py $1 --settings=settings_debug
}
alias mng=mymanage

Then when you run this command:
mng runserver

settings_debug.py file will be used for settings.
Answer: You can use django-admin.py with that environment variable. Commands are interchangeable, only django-admin.py doesn't override the variable you're trying to use.
Answer: If a settings file is common to all installation, you can just import it e.g.
from settings_local import *

but usually settings_local are changed and tweaked per installation and as my installation script directly copy files to target sites (without worrying what is local what is not), which mean settings_local may get overwritten, to avoid that I just keep settings_local in parent folder of the installation target and manually import it in settings.py e.g.
local_settings_file = os.path.join(prevFolder, "settings_local.py")
if os.path.exists(local_settings_file):
    execfile(local_settings_file)

django manage.py settings default


Menu bar HTML/CSS bad showing

Question: I want to create a menu bar with a list, but it's all in one place!
If I play with the position of the menu (absolute, fixed, ...), it's good, but I want that the menu will be fixed.
CSS:

img.logo {
  max-height: 90px;
  width: auto;
  position: fixed;
  clip: rect(5px, 95px, 90px, 5px);
}

a,
li {
  color: inherit;
  list-style: none;
  text-align: center;
  display: inline-block;
  padding-right: 10%px;
  padding-left: 5%;
  padding-bottom: 10px;
  font-size: 40px;
  font-family: Odin rounded;
  vertical-align: text-top;
  position: fixed;
  text-decoration: none;
}

li {
  border: 1px solid black;
}

***HTML:***
<!DOCTYPE html>

  <title>Team NoMaD</title>
  <link rel="stylesheet" href="css/styles.css">
  <meta charset="UTF-8">

Menu

Membres

Calendrier

Contact

Run it and you will see what I see...

What is wrong?
PS: Can you say how can I make it all in one line, like a real menu bar
Comment: remove position fixed from your li,a and reduce your left and right padding (or make them px instead of %)
Comment: Check `padding-right` value in `a, li` **10%px**
Answer: You should remove position:fixed from img-logo, a, li and add position:fixed or position:sticky to their parent container

.navbar{
  float: right;
  position: sticky /* use can use position:fixed */
}

 img.logo{
 max-height:90px;
 width:auto;
 clip: rect(5px,95px,90px,5px);
}
a, li{
 color:inherit;
 list-style:none;
 text-align:center;
 padding-right:10px;
 padding-left:5px;
 padding-bottom:10px;
 font-size:16px;
 font-family:Odin rounded;
 vertical-align:text-top;
 text-decoration:none;
    display: inline-block;
}
li    {
 border:1px solid black;
}

 <title>Team NoMaD</title>
 <link rel="stylesheet" href="css/styles.css">
 <meta charset="UTF-8">

Menu

Membres

Calendrier

Contact

Comment: And can you say me how can I put all in one line, like normal menu bar (like stackoverflow menu bar on the top)
Comment: You mean vertical line??
Comment: stack overflow has two menu vertical on the left and horizontal one the to right
Comment: I mean on the top, where is the search bar
Answer: I've made a few changes by simplifying your css content.
You just need to use display: block and float:left to arrange your menu items properly. I've added a few more tweaks to it to suit what you wanted to achieve.

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

li {
    float: left;
    border: 1px solid #000;
}

li a {
    display: block;
    color: #000;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}
<!DOCTYPE html>

 <title>Team NoMaD</title>
 <link rel="stylesheet" href="css/styles.css">
 <meta charset="UTF-8">

Menu

Membres

Calendrier

Contact

Answer:

<!DOCTYPE html>

 <title>Team NoMaD</title>
 <link rel="stylesheet" href="css/styles.css">
 <meta charset="UTF-8">

Menu

Membres

Calendrier

Contact

Just changing display:inline-block to inline worked for me. Preview this on full page as this is not responsive example.
Hope This could help. :)

Menu bar HTML/CSS bad showing


Finding the basis for a subspace and relating it to the basis of the vector space

Question: Let's say we have a subspace $U$ defined by the set:
$U = span {((1, 2, 1, 2),(2, 1, 2, 1),(1, 1, 1, 0))}$,
which exists within a vector space $V$, where $V = \mathbb{R}^4$.
I've been asked to find the basis for $U$, which I found to be the set:
$((1,2,1,2),(0,1,0,0),(0,0,0,1))$, using row reduction of the matrix composed of the spanning set. But then the next part of the question asks me to 'complete the basis of $U$ to a basis of $V$'. I don't understand what the question means by 'completing'. Could anyone offer advice?
Comment: Note that $((1, 2, 1, 2),(2, 1, 2, 1),(1, 1, 1, 0))$ is a perfectly valid basis for $U$ as well. (Assuming they are linearly independent, which I haven't checked myself.)
Answer: It means choosing a fourth vector so that your set spans $R^4$


Passing object to a WebMethod through jquery ajax

Question: I am trying to pass an object to a page method defined. I'm trying to pass data to it collected from three textboxes.
Page Method
<code>    [System.Web.Services.WebMethod]
    public static string saveDataToServer(object csObj)
    {
        // Function Body.
    }
</code>
Javascript/jQuery
<code>        $("#osmSendMsg").click(function () {
            debugger;
            var cntDetails = {
                 cntName : $("#osmContactName").val(),
                 cntEmail : $("#osmContactEmail").val(),
                 cntMsg : $("#osmContactMessage").val()
            }
            PostDataToServer(cntDetails,"Please wait...","/ContactUs.aspx/saveDataToServer","csObj");
        });
</code>
PostDataToServer
<code>// Post data to server (ajax call).
function PostDataToServer(dataToSend, strMessagetoShow, strMethodToCall, jsonObjectName) {
    debugger;
    /*
    dataToSend          Contains the JSON Object.
    submitType          1 == Normal Submit; 2 == Submit and Print.
    strMessagetoShow    Text that is displayed in the Please Wait Window.
    */
    var tempurl = strMethodToCall;
    var tempdata;
    $.ajax({
        url: tempurl,
        type: "POST",
        async: false,
        dataType: "json",
        data: "{" + jsonObjectName + ":" + JSON.stringify(dataToSend) + "}",
        //timeout: 30000,
        contentType: "application/json; charset=utf-8",
        success: function (data) {
            tempdata = data;
        },
        error: function (result) {
            tempdata = null;
        }
    });  //end of the ajax call
    return tempdata;
} //End of the post Data
</code>
Now the call is reaching the web method. No problem. I'm getting the object as well.But how do I process the object?

As you can see, that's what I'm getting. I also tried declaring a class and passing it as the parameter..but all it's properties are empty. If you notice the data is appearing as a key, value pair. I could convert it into a Dictionary, but I believe that's a complicated solution.

A simpler solution would be welcomed!
Comment: See http://stackoverflow.com/questions/13175652/json-postback-to-c-sharp-webmethod-add-literal-control
Comment: Okay, this worked. Sending it as a string, and splitting it on the server side.
Answer: Your result collection is being returned in the 'data' parameter of your success method. You can simply process this parameter directly like data[0].cntName.
Comment: No, I'm trying to get the data on the server side, not the client side. Currently it's coming as a `object` type, but I am unable to process that object.
Answer: As you are able to reach your webmethod, you need to modify your webmethod to read the data from the object as follows:
<code>    [System.Web.Services.WebMethod]
    public static string saveDataToServer(Dictionary<string, string> csObj)
     {
            try
            {
                 string Name = csObj["cntName"].ToString();
                 string Email = csObj["cntEmail"].ToString();
                 //you can read values like this and can do your operation
                 return "";//return your value
            }
            catch(Exception ex)
            {
                  throw new Exception(Ex.Message);
            }
     }
</code>


Span of a set of vectors containing the zero vector

Question: I'm sorry if this is a stupid question, but if I have a set of $3$ vectors, one of which is the zero vector, and the question asks if the set of these three vectors spans $\mathbb R^2$, why is the answer yes?
I thought the three vectors had to be linearly independent to span $\mathbb R^2$, but if one of the vectors is the zero vector, isn't the set linearly dependent?
I even came across another question in the problem set asking to check if two vectors were linearly independent, and one of the two vectors was the zero vector and the answer was that they are not linearly independent. I'm just a bit confused.
Thanks!
Comment: You seem to be confusing the span of a set of vectors with a basis for a vector space. A basis has to be linearly independent, but the span of a set of vectors is simply the set of all linear combinations of them. It doesn't matter whether or not they're linearly independent.
Answer:
if I have a set of 3 vectors, one of which is the zero vector, and the question asks if the set of these three vectors spans R2, why is the answer yes?

The answer is not necessarily yes.  For example, consider
$$
\{(0,0),(1,1),(2,2)\}
$$

I thought the three vectors had to be linearly independent to span R2,

No. A set of two vectors must be linearly independent if it spans $\Bbb R^2$.

but if one of the vectors is the zero vector, isn't the set linearly dependent?

Yes, that's right.
Comment: Right, so if I am given a set of four vectors, and asked if it spans R3, if three of those vectors are linearly independent it doesn't matter if the fourth one is isn't, the answer will be yes, it does span R3?
Comment: That's exactly right.
Comment: Well, it's mostly right.  It's not clear what you mean by *"if the fourth one is isn't"*.  A vector can't be "linearly independent/dependent" in its own right.  However, the main idea is correct: if a set of three vectors span $\Bbb R^3$, then adding any other vector will yield another set that spans $\Bbb R^3$.
Comment: My issue was, in the question they set up a span of 4 vectors, and asked if it was "true" that they spanned R3. I found the RREF and found that there were 3 pivot columns. So I am wondering, by what you have said, that if 3 of the four vectors in the span are linearly independent (because there are 3 pivot columns), does that mean the span the question gave me, with all four vectors does span R3? Because what I learned in class was that when given a set of 4 vectors, all must be linearly independent in order to span R3 (which is impossible) which is why I was inclined to answer false.
Comment: From what I learned in class, I would've thought that the span from the above question should only contain the three linearly independent vectors, not the fourth in order to span R3. Just wanted to know if my thinking is, well, very very wrong.
Comment: *"given a set of 4 vectors, all must be linearly independent in order to span R3"*: this is false.  The **dimension** of $\Bbb R^3$ is $3$; $3$ linearly independent vectors are needed to span $\Bbb R^3$, and any linearly independent spanning set of $\Bbb R^3$ has exactly $3$ vectors.  Similarly, then dimension of $\Bbb R^n$ is $n$.  In class, did you talk about the space polynomials of degree $3$ by any chance?
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/49668/discussion-between-aa21-and-omnomnomnom).
Answer: Since $\Bbb R^2$ has dimension $2$ so any two linearly independent vectors will span it.
No matter what the third vector be(even $0$) it will span $\Bbb R^2$ provided the other two vectors in the set are linearly independent
Comment: I'm very confused, I also read that if the question gives me a set of four vectors and asks if spans R3, then the answer is no because only three vectors can span R3. How can any set span R2 if it has more than two vectors?
Comment: A set of vectors will span a space if every vector in that space can be written a linear combination of them. In order for this to be possible the number of vectors in the set must be at least as big as the dimension of the space, but it can be bigger than the dimension. However, if it is bigger than the dimension the set will not be linearly independent. If the set is also linearly independent then that means that every vector in the space can be written UNIQUELY as a linear combination of those vectors in the set.
Answer: A set of two vectors has to be linearly independent in order to span $\Bbb R^2$. If your set contains more vectors than that, then it is enough that you can find two linearly independent vectors among them.


How to find the number of solutions of $6|\cos x|=x$?

Question: Now, I think the only way to solve this problem for a high school student was graphically.
However using pen and paper to draw the graph, it was virtually impossible to justify or refute the existence of the "Fourth" solution.
Using desmos, I realised that we must must work on the the existence of the Fourth solution analytically because $ y=x$ is really close to $6|\cos x|$ at the potential Fourth solution.
You can see for yourself.

So, this being a high school problem, is there any way to predict whether $y=x$ will intersect $6|\cos x|$ or not?
With enough zoom we can see that $y=x$ does not intersect $y=6|\cos x|$. However, how could have I predicted this with a pen and paper?
I am acquainted with calculus but had no clue how to go about it.
Thanks for your time!
Comment: @AdityaSharma, Use IVT for continuous functions.
Comment: With enough zoom, you can see there is no $4^{\mathrm{th}}$ solution, as in [link](https://www.wolframalpha.com/input/?i=Plot%5B6+Abs%5BCos%5Bx%5D%5D+-+x%2C+%7Bx%2C+-2%2C+7%7D%5D).
Comment: Yes, I have emphasised that in the question, How could have I predicted that with a pen and paper?
Comment: I would approach this by manually graphing, and then see that $\cos{x}$ will oscilate among 0 and 6, therefore all our answers should be in that range
Comment: I am unable to see how that helps me find the solution..   Can you please guide me?
Comment: This was a high school problem? Probably a mistake right?
Comment: Here's a [similar question](https://math.stackexchange.com/questions/3277925/solving-equations-involving-x-pi-cos-x).
Answer: [Using some calculus]
It's enough to consider $3\pi/2 \lt x \lt 2\pi$. In that range the cosine is positive, so we can dispense with the absolute value and  consider the function $f(x) = x - 6\cos(x)$, show that its minimum is positive and that its second derivative is positive.
To get the minimum, we set the derivative equal to 0:
$$f'(x) = 1 + 6\sin(x) = 0 \implies x = \sin^{-1}(-1/6) \approx  6.1138 > 6,$$
remembering the restriction on the values of x we are considering. Since the cosine cannot be greater than 1, $f(x) = x - 6\cos(x) > x - 6 > 0$ at $x \approx 6.1138$, so the extremum is positive.
The second derivative is $f''(x) = 6\cos(x) > 0$ since the cosine is positive in the interval we are considering, so the extremum is a minimum and the function is concave up throughout that interval.
Therefore $f(x)$ has a positive minimum and is concave up, so it is never 0 on the given interval.
Comment: Nice, +1 (you can also use the fact that $\cos(\arcsin(x))=\sqrt{1-x^2}$ to show that the minimum is positive).
Comment: Thanks! That does it for me!
Answer: I know this not necessarily relevant, but some high school students take calc. Keeping this in mind what I would suggest to a student is that this is the same as solving $6|\cos(x)| - x =0$ which itself is equal to two problems for each positive and negative side of the absolute values.
For example the positive $6\cos (x) - x = 0$ then there is a Taylor expansion of the cosine and take it to the forth power for example and solve that polynomial for its roots. I think does not solve the problem with pen and paper but it is an approach that also is valid. (Also you do not have to really solve the polynomial you. just have to say something about it's roots)
Comment: If I take the expansion only up to 3 terms, isn't that still an approximation? How do I know it is a solution of the original equation?
Answer: Here is my approach for solving it analytically: It's a far stretch from proof, but surely sufficient for high school maths :)
So if, at the fourth solution, $g(x)=6\cdot\vert\text{cos}(x)\vert$ crosses $f(x)=x$, there would either need to be a 5th solution or $g$ is precisely tangent to $f$ at this point, i.e., has slope $g\text{'}(x)=1$.
Case 1: $g(x)=f(x)$ has only four solutions, so we have $g\text{'}(x_4)=f\text{'}(x_4)=1$. We know by heart, that, in the relevant domain: $$g\text{'}(x)=6\cdot(\text{cos}(x))\text{'}(x)=-6\cdot\text{sin}(x)$$
This tells us about the unknown $x_4$ that $$-\text{sin}(x_4)=1\backslash 6\iff x_4=-\text{sin}^{-1}(1\backslash 6)=-0.1674480792+n\cdot2\pi$$ for some $n\in\mathbb{Z}$. So is there some $n\in\mathbb{Z}$ such that $\text{cos}(-0.1674480792+n\cdot2\pi)=-0.1674480792+n\cdot2\pi$? Plugging in a few small integer values for $n$ we quickly see that the answer is no! Proceeding to case 2:
Case 2: There exists not only a 4th, but also a fifth solution $x_5$ to $g(x)=f(x)$, where we see on the intuitively drawn graph that $x_4$ and $x_5$ must be very close to each other. The point that we calculated before, where $g\text{'}(x)=f\text{'}(x)$, i.e., where the tangent of $g$ has the same slope as the tangent of $f$, must in this case lie above $f$ (Draw a picture!). So does there exist some $n\in\mathbb{Z}$ such that $\text{cos}(-0.1674480792+n\cdot2\pi)>-0.1674480792+n\cdot2\pi$? By plugging in small $n$, we see that the answer is no in the relevant domain! (There does exist one solution but it's between the second and third intersection of $g$ and $f$, i.e., doesn't tell us anything about the fourth or postulated fifth one)
So $g(x)=f(x)$ only has three solutions.


Different domain names to site languages

Question: I have a Multilingual Drupal 7 site. The site is in 3 languages Dutch (default), English and German. The multilingual setup is done based on the i18n module. All is setup and works great!
Dutch site: litebook.eu
German site: litebook.eu/de
English site: litebook.eu/en
But now i have 2 more Domain names i have to use: litebook.de and litebook.co.uk
I want:
- litebook.de to go to litebook.eu/de
- litebook.co.uk to go to litebook.eu/en
What is the best way to set this ups and what do i have to do exactly?
Thanks a lot!
Answer: the simple way will be to use .htaccess
<code><IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^litebook.de$ [OR]
  RewriteCond %{HTTP_HOST} ^www.litebook.de$
  RewriteRule (.*)$ http://litebook.de/de/$1 [R=301,L]
  RewriteCond %{HTTP_HOST} ^litebook.co.uk$ [OR]
  RewriteCond %{HTTP_HOST} ^www.litebook.co.uk$
  RewriteRule (.*)$ http://litebook.eu/en/$1 [R=301,L]
</IfModule>
</code>
Comment: Thanks. And what is the other way?
Comment: you can also you Drupal Redirect model "https://www.drupal.org/project/redirect" please don't forget to accept the answer.
Comment: I will accept. And do you know what is the [Domain Access](https://www.drupal.org/project/domain) module for? Is this module handy to use in my case or is it for something else? Thanks
Comment: I never used it before but it seems to be active module a lot of site reported using it.
Comment: What i try to understand is: What is Domain Access module different then using redirect method? Thanks
Comment: I have never used it so i can really comment about it.
Answer: Here is an attempt to complete the previous answer, specific to the extra comment by OPer added to it, which is "What is Domain Access module different then using redirect method" ...

"using redirect method" is like instructing the browser with something like so: "If somebody enters an URL like, then do not display the content located at that URL; And instead, display the content of the redirected URL".
The Domain Access module is used (as mentioned on its project page) for:

running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites.

Obviously, the redirect method has nothing to do with such "sharing" ... The redirect method doesn't know anything about such sharing of databases. Maybe one could say also "doesn't even care why the content of some other URL is to be shown as a replacement of the redirected URL".


Can't use referenced color (by theme) in drawable

Question: Consider:
styles.xml

attrs.xml
<attr name="theme_color" format="reference" />

color.xml
<color name="theme_color_blue">#ff0071d3</color>

and finally the drawable progress_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/background">
        <shape>
            <stroke
                android:width="2px"
                android:color="#ff515151" />

            <solid android:color="@color/transparent" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid android:color="?attr/theme_color" />
            </shape>
        </clip>
    </item>

</layer-list>

when using progress bar drawable:
<ProgressBar
    android:id="@+id/progressBarStartup"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:progressDrawable="@drawable/progress_bar"
    android:visibility="visible" />

I get a runtime error. It seems Android can't get the color theme.
06-24 16:35:57.032: E/AndroidRuntime(3493): java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx.xxx.activities.startup.ActivityStartup}: android.view.InflateException: Binary XML file line #33: Error inflating class android.widget.ProgressBar

06-24 16:45:32.265: E/AndroidRuntime(9901): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010000 a=-1}

Comment: Try cleaning the project. Eclipse sometimes messes up the ids.
Comment: This line @style/android:attr/progressBarStyleHorizontal doesn't look right.
Comment: Yes sorry, I edited the question.
Comment: Which line coresponds to line #33?
Comment: <ProgressBar, it's not very precise in this case...
Answer: Yes, this seems to be a known problem. But there is a workaround. Instead of using ?attr referenced colors like you described, create several drawables (as many as the different colors you have), let each call its colors directly. On the theme level, reference to the drawables themselves depending on the theme. It works that way.
Update:
On Lollipop, you can tint the drawable in XML. To cover pre-Lollipop, you can simply call this for all your drawables in question (thanks to the newer versions of the appcompat library):
public void setDrawableColor(Drawable d, int color) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    d = DrawableCompat.wrap(d);
    DrawableCompat.setTint(d.mutate(), color);
  }
}

Comment: Unfortunately, this is still the only workaround available, short of using Lollipop only where you can color your drawables. I have 12+ themes in one of my apps and yes, it's a PITA to have so many variants for the drawables but that's how it works. But I changed the wording to say more than two if necessary.
Comment: Why do you think he only has two themes? If he has 200 themes, I don't see how your answer is correct. I think the real point of your answer is: You cannot single source the color in this use case.
Answer: You should use <attr name="theme_color" format="integer"/>


Does using JMS in the middle of a Apache Camel route guarantee delivery?

Question: According to Apache Camel documentation, "Camel supports the Guaranteed Delivery from the EIP patterns using among others the following components: ... JMS."
I'm trying to understand if this means I can use JMS in the middle of a multi-component route to "guarantee delivery."
For example, I have some routes that looks like this:
from("rest://post:someRestRoute")
    // blah blah
    .to("jms:queue:someQueue");

from("jms:queue:someQueue")
    // blah blah
    .to("spring-ws:someAddress")
    .to("someOtherRoute");

Does using JMS in the middle of a multi-component route have any benefits? Camel is writing to and reading from the queue, and the queue is running on the same computer and same JVM, so Camel is only guaranteeing delivery to itself, which seems redundant.
For example,

A message is POSTed to someRestRoute.
The message is queued and persisted on someQueue.
The message is immediately dequeued.
The message is sent to a webservice at someAddress.

As I understand it, as far as the JMS broker is concerned the message is "delivered" the moment it's successfully dequeued; it doesn't matter if spring-ws:someAddress throws an exception. I suppose this might be helpful if Camel crashed immediately after step 2, but I was hoping to guarantee delivery to someAddress.
Does using JMS in the middle of a multi-component route have any benefits? Can it be used to "guarantee delivery" to someAddress in the example?
Answer: Only if your JMS queue is defined to persist messages. Then in case your route/application/server stopped before picking message, it will be in the queue until processed next time when route starts.
If you do not need persistence then there is no reason to have JMS.
Camel can be set to retry delivery to the endpoint in case of failure.
But, if you need persistence JMS is the best (if not only one) way to do it.
Comment: I'm having trouble understanding why the message would ever stay on the queue for more than a few milliseconds. The application is already processing the message, so why place it on a queue to immediately take it off again?
Comment: h-m-m-m... let say you need a guarantee delivery and in some situation message was placed, but not picked because many requestes coming, JVM runs fullGC or crushed, server rebooted, power went off etc. Then you need a persistence
Comment: Another and more important case is for clustered environment. if it is direct: direct-vm: seda: kind of endpoint it runs in one JVM or CamelContext). Having JMS in between allows to process message in any numbers of other servers.
Comment: you are always welcome. Generally speaking main porposes of JMS are: 1. decouple publishing from processing. 2. deliver same message to multiple consumers (if it is a Topic or consumers use filters on Queue) 3. Guaranteed delivery. If nothing of it is a case and all can be processed straight forward in one JVM/CamelConext then there is no reason to have JMS in between. Performance will be better and less resources needed, such as IBM MQ, ActiveMQ etc...


opencart admin no image thumbs

Question: I'm using opencart ver 188.8.131.52 for a personal project, using Ubuntu 17.10 and I got a strange behaviour configuring the Apache server (Apache/2.4.27) or the admin/config.php files. I don't know, probably both.
The Catalog section is working just fine, but in the administrative (Admin) one, thumbs images are not displayed correctly. I mean, all menu functions are displayed correctly, but for example, in product section, the element thumbs are not displayed, nor the product image in its section. Using the "inspect" Chrome function I can see that the thumbs are pointing to an incorrect path:
This is the link showed in the inspect section:
<img src="image/cache/catalog/<dir>/<file-name>" alt="<name>" class="img-thumbnail">

When I pass the mouse over it, it display the complete path:
http://192.168.1.123>/<site-name>/admin/image/cache/catalog/<dir>/<file-name>

Here, the " /admin/ " element is the one that prevents the link working. The url should be:
http://192.168.1.123/<site-name>/image/cache/catalog/<dir>/<file-name>

as stated in admin/config.php:
define('DIR_IMAGE', '/var/www/html/<site-name>/image/');

The HTTP & HTTPS sections in admin/config.php:
// HTTP
define('HTTP_SERVER', '');
define('HTTP_CATALOG', '');

// HTTPS
define('HTTPS_SERVER', '');
define('HTTPS_CATALOG', '');

And the .conf in /etc/apache2/sites-available/
<VirtualHost *:80>
     ServerAdmin <email>
     DocumentRoot /var/www/html/<site-name>
     ServerName <site-name>
     ServerAlias www.<site-name>

     <Directory /var/www/html/<site-name>/>
        Options FollowSymlinks
        AllowOverride All
        Order allow,deny
        allow from all
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

How can I configure correctly the opencart admin section? I tryied so many combinations but I can't figure the reason for this behaviour. Thanks!
Answer: As expected, as I wrote for help, 5 minutes after I got the the solution:
The issue is caused because of cross-domain policies when the frontend or the admin panel are accessed from a different address than the one configured in the OpenCart config files. For example, if you have installed your OpenCart for the address http://address but you access your site via http://www.address you will experience such issue. The solution to this is fairly simple. Open config.php file from OpenCart root folder as well as config.php from the admin folder and make sure HTTP_SERVER and HTTPS_SERVER point to www location. For example:
config.php - OpenCart root folder
// HTTP
define('HTTP_SERVER', 'http://www.example.com');

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com');

config.php - OpenCart admin folder
// HTTP
define('HTTP_SERVER', 'http://www.example.com/admin/');
define('HTTP_CATALOG', 'http://www.example.com/');

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/admin/');
define('HTTPS_CATALOG', 'http://www.example.com/');

I'm letting this here in case could help...
Bye!

opencart admin no image thumbs


D6: Create block view which returns all nodes with related terms

Question: I have a vocabulary which contains a large number of terms, most of which have been given relationships to other terms.
I want to create a block display of a view which takes the term from the current node and displays all the other content which has a related term from the same vocabulary.
So far, I have been able to return all nodes with the same term using this as a views argument:
<code>node = node_load(arg(1));
if($node) {
foreach($node->taxonomy as $term) { $terms[] = $term->tid; }
return implode('+',$terms);
} else { return; }
</code>
However, I haven't been able to combine this with taxonomy_get_related to return nodes related by term.  Any suggestions?
Answer: You probably have to do the follwing:

create a view
add a block to that view
add a contextual filter (in Drupal 6 it is an Argument)
configure it with:

Action to take if argument is not present: Provide default argument
Default argument type: Node ID from URL
Validator: taxonomy term
You can use Term ID from the URL, or try to use the term name.

Then you have to save and configure the block to show on the desired page...
These settings in Drupal 7 (more or less, there are some slight differences in interface) work for me...


ModelSim PE Student Edition 10.1c (STD_LOGIC error)

Question: I am trying to use STD_LOGIC in my VHDL code. It will not compile because the STD_LOGIC I am trying to use in the port(.....) section is not working. I know the problem is because I did not import the IEEE library. I tried to import it but I was not successful.
How to import the IEEE library properly to a VHDL program in ModelSim?
Answer: To import the package that defines the std_logic type to a VHDL design, add the following two lines to the top of your VHDL file:
library ieee;
use ieee.std_logic_1164.all;


Test of Significance of Different Surgeries

Question: I have a dataset about nose surgeries done in several years. Some surgeries were combined, e.g. multiple procedures were done during one surgery. After some surgeries, some complications appeared. My task is to determine if there is a statistically significant difference in the frequency of surgeries between combined and independent surgeries. It is assumed that the combined surgeries should have a higher percentage of complications, yet it has to be prooved.
<code>|                        | Independent | Combined |
|------------------------|-------------|----------|
| Without a complication | 31          | 123      |
| With a complication    | 10          | 65       |
</code>
Please note there were complications in 24 % of independent surgeries and 35 % of combined surgeries, which is quite a big difference in my opinion.
I used the Chi-Square test of independence, which is as-far-as-I-know the most typical test for this type of task, yet the result is not statistically significant ($\alpha = 0.05$), I had the same result with the Fisher's Exact test. Is there some other test I can try? I found the usage of t-test in some research papers for similar tasks, yet in my opinion, it is not possible to use it here. Or I am missing something?
Answer: You make the following hypothesis : "there is no difference IN THE FREQUENCY OF COMPLICATION following simple VS combined surgery.
And you want to refute that hypothesis using statistics ? Fine.
This should be translated into "the difference between frequency of complication after simple surgery and the frequency of complication after combined surgery is not statistically different from zero"
Then your first step is to calculate that difference. That, you can do only once because you only have one estimate of frequency of complication for each group.
However you actually need a SAMPLE of INDEPENDENT such estimates, for using statistics. For example, one estimate of each frequency for N hospitals.
In your case, you have only one estimate for each group. Then you can calculate only one estimate for the difference between those two groups.
The logical conclusion is that what you have AT BEST is a point-estimate of that difference.
You CAN NOT estimate significance using such point-estimate.
I am really sorry for you but at best you can argue that the difference is not zero IN YOUR STUDY and that it could mean more INDEPENDENT indentical studies should be made, maybe in different hospitals, for strengthening your conclusion WHICH IS NOT BACKED BY STATISTICS for the time being.
Answer: Tests you used are fine, you should just accept your results. The point of statistics is not to keep trying tests until you get results you like.
HOWEVER, just because the difference is not statistically significant, that does not mean that the rate of complications is the same. That's the old absence of evidence is not evidence of absence. What you can do is to look at confidence intervals around the difference between the surgeries and say that 0 difference is compatible with the observed data, but huge difference is also compatible with the data. So if you think that there is a difference, than this trial would not convince you otherwise, but also not really prove it either.


Bulk delete orders

Question: I have a bunch of test orders and I'd like to remove them. Is there a way to bulk remove all of the orders without uninstalling/installing the Ubercart module?
Obviously, I'd first backup the database with a simple drush sql-dump.
Comment: You can try flushing the orders MySQL table using phpMyAdmin or any db management tool. If you do please backup your database and test if everything is ok.
Comment: Have you done this before ? Are you sure you don't forget some child tables like `uc_order_line_items` ? It won't bother Drupal to have these lines left in your tables but it's not a good advice to give.
Answer: I would discourage you from messing with the database unless you really know what you're doing. You should better use the API and the function uc_order_delete().
Have a look at this example script:
<?php
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

  global $user;

  if ($user->uid == 1) {
    $result = db_query("select order_id from uc_orders");
    while($row = db_fetch_object($result)){
      //# uncomment below to view an order and exit
      //# usefull to write a query to only delete certain orders
      //print_r($row);
      //exit;
      print "deleting order $row->order_id\n";
      uc_order_delete($row->order_id); // comment this out for testing
    }
  } else {
    print "Only Administrater could deleter orders.";
  }
?>

Source: Delete all orders in Ubercart.
Comment: Or use this [Bulk delete orders](http://drupal.org/project/vbo_delete_uc_orders) module , so you can do bulk delete from _admin > store > order_ itself.
Answer: You can use a view created with the Views Bulk Operations (VBO) module to delete orders.

This module augments Views by allowing bulk operations to be executed on the displayed rows. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied. Drupal Core or Rules actions can be used.

Bulk delete orders


redirect to prod url when creating content

Question: I have a Drupal 7 development site that is a subdomain of the production site, eg. dev.prod.com, for example.
When ever I create a content type, new content, a new user, install a new module, etc on the development site it redirects to the production URL after the form is submitted.  I don't have permission on production so I get "access denied". When I go back to the development site and refresh the browser, the content have been created.  But this does not work for installing a module. The module is not installed.  Obviously, this makes it impossible to work on dev.
I have reviewed .htaccess and settings.php for any rewrite rules that could be causing this but I have not found anything.  $base_url is set to the correct URL for the development server. I have cleared the cache many times.
Any suggestions?
Comment: Is there a `$base_url` set in settings.php? https://api.drupal.org/api/drupal/developer!globals.php/global/base_url/7.x
Answer: Looks like you need to check the value specified for $base_url, within the settings.php of your dev.prod.com site. Assign a value of (eg) dev.prod.com and see what happens then.
Comment: That's the first thing I tried.  Same problem.  And I cleared the cache multiple times.