How can I breakup my large Backbone.js project into sections?

Question: I have 1 controller with hundreds of routes.  Is there a system to break up an app into sections and only load the javascript files needed for that section?
Otherwise the user might have to download all the javascript for the entire app from the first load.
Seems like on certain controller hits, it should detect if a new download of javascript is needed.
Answer: You could look into RequireJS.
Just remember that loading modules dynamically has it's downsides as well:

Application is less responsive, each time you load new module user has to wait.
Code can get more complex as you can only execute certain parts only once something has been loaded.
And some more complex problems in specific applications.

Ideally you want to keep your module/multiple file approach, but for deployment merge everything in one file. Even if it's a huge file it will still load faster than say 50 files and be more pleasant for user than having to see loading screen each time he navigates to different part of the application.
I think RequireJS offer both things, you can load things on the go when you develop, but when you're ready for deployment you still can package all in one file.
Comment: RequireJS has an optimization tool which does exactly what you suggest. Also, though the documentation is a bit quiet on this, it lets you use syntax like `var CoreModels = require('models/core');` inside each define(), so you get Python-style imports in Javascript :)
Answer: I recommend using asset packager such as Jammit that will minify your multiple scripts into one compressed one on demand.
This way you can structure your scripts however makes more sense to you, break them into as many files you wish, and the asset handle will take care of compressing and combining them.
If some scripts are way too big to be loaded everywhere, you can always move loading of bigger scripts into views that need these scripts using content_for
For instance:
<code><% content_for :head do %>
  <%= include_javascripts :my_big_files %>
<% end %>
</code>
Comment: Jammit can't even shake a stick at the asset pipeline these days.
Answer: Another option for you could be Stitch. It is a part of the node eco system, and can compile coffeescript on the fly.
https://github.com/sstephenson/stitch


Which strings do I pick when arpeggiating a G chord on guitar?

Question: I'm trying to play this as part of an arpeggiated version of Hallelujah. For arpeggiating C, Am and F cord I find it easy to know which strings to pick and it sounds right. But when doing the same for G it sounds off.
For example on C cord I pick the (6th is low E) 5th, 4th, 3rd (open) and 2nd string and it sounds fine. But for G I pick the 6th, 5th, 4th (open) and 1st string (as those are the ones fretted plus one open string to keep the meter) but it doesn't sound right. Am I doing it wrong? I have standard tuning by the way.
I think my issue is the 3 open string gap between the fretted 5th and 1st string on G chord and not knowing which to pick if any.
Comment: Try all the possibilities and choose the one you like best.
Answer: The open strings are all part of the chord so there's no reason for you to primarily target the fretted notes. The notes in the G chord are G, B, and D - so the open G, B, and D strings fit in very naturally. In fact I often avoid playing the 5th string in the G chord because, while it is part of the chord, it can sound a little "muddy". I also notice that you're playing strictly from the bottom E string and up - you can also go in the other direction if you want, or even switch directions.
Here are a few options to try (though I'm not too familiar with the song so I'm not sure how well they fit, but they should give you some idea perhaps):

You can try similar patterns on the other chords as well, but there are really no limitations - try to experiment and see what kinds of patterns you can find.
Answer: Any string that's open or fretted for a particular chord is good to use for that chord. When arpeggiating on guitar, the go-to is root on the 6th or 5th string, and some other notes contained within the chord.
With a C chord, there are three options for a low note - bottom string open (the 3rd of the chord), bottom string 3rd fret (the 5th of the chord) and fifth string 3rd fret (the root). Generally, that root sounds most stable, but any of the three will work. What else you pick will be down to what you think sounds good, and there are many optional combinations.
With a G chord, root is bottom string 3rd fret, third is fifth string 2nd fret, and fifth is D string open. Again, all will work, and there's also another voicing choice of B string open or B string 3rd fret.
You, as the player, can choose which combination gets used, so get the ears working, and try all the options. There is no absolute right way, unless you want to copy the original, but that actually may still not be the best - it's subjective.
Answer: I normally play Hallelujah in Bb rather than C, using a rather unusual tuning that happens to go down to D, but the voicings I use could also work in C major, Standard tuning if fingered as shown.  Play the lowest three sounding strings in each group individually for the for the first three eighth-note beats, and then the last two together for the next quarter or dotted quarter.  Ideally, repeat the first note of each group on the upbeat just before moving on to the next chord, but if you can't, just get ready for the next chord.
x-3-5-5-[5-3]  C
5-x-7-5-[5-5]  Am
1-x-3-2-[1-1]  F
3-x-5-4-[3-3]  G
0-x-6-4-[3-4]  E7 or
0-x-2-4-[3-4]  E7 or
0-x-2-4-[3-3]  Em7

The Hal Leonard sheet music puts a dominant 7th on the second syllable of "composing", which I like better than the  minor chord used in many other arrangements.  IMHO, the "secret chord" is a dominant seventh with parallel thirds resolving up to parallel roots on the next chord, and with the downward-resolving seventh between them.  One could use an E7 voiced as 0-x-2-1-[0-0] or Em7 voiced as 0-x-2-0-[0-0] but if you can play the E7 with the double tritone the effect is very powerful.
Answer: When breaking chords on a guitar, the typical way to do it is to play the bass note (usually the root) on one of the lower three strings, and then the three highest strings. Any other choice of strings is relatively uncommon.
In the case of the G chord, the most likely way to play it broken is as 3xx003, or in case of the barré version, 3xx433. (That's G on the low E, and then either G-B-G or B-D-G on the G, B and high E.) The rhythm in which you play the strings depends heavily on the rhythm of the song; about all that tends to stay the same is that the bass note is played at the first beat of every bar.
(Of course, none of these are strict rules and it's entirely possible to make other choices.)


Clarification of excerpt regarding Souslin Lines

Question: Here is an excerpt from Mary Ellen Rudin's Lectures on Set Theoretic Topology during her discussion about Souslin Lines and Trees,

What is exactly meant by "Collapse each of these intervals to a point and add the first and last point to the space?" My question is essentially, is there a more descriptive way to describe this set $S'$?
Answer: I find this description quite descriptive enough. Let the set of maximal non-trivial closed intervals that are separable be called $\mathcal{I}$. The family  is pairwise disjoint (if two of them intersected, their union would be a larger  such interval, contradicting maximality. Their interiors are non-empty and disjoint so $\mathcal{I}$ is countable as a Souslin line is ccc. Now take the equivalence relation that has as elements all members of $\mathcal{I}$ and all $\{x\}$ with $x \in S\setminus \bigcup \mathcal{I}$. The order on $S$ induces an order on the quotient space, because all classes are order-convex (we identify all intervals in $\mathcal{I}$ to a new point) (i.e. define $[x] \le [y]$ iff $x \le y$ and check this is well-defined). Then take $p,q$ two new points (not in $S$ or the quotient) and extend this order by $p < x < q$ for all $x$ in the quotient (adding a minimum and a maximum). This new ordered set is our $S'$. $S'$ is order complete if $S$ was, so if complete, it will be compact (which in ordered spaces is equivalent to every subset having a minimum, hence the need for the min and max).
Comment: And for linearly ordered spaces we have that ccc implies hereditarily ccc and hereditarily Lindelöf. And combining with the compactness we get perfectly normal and first countable too. A very nice L-space.
Comment: Thanks so much. I believe the main idea I was missing is that they *had* to be disjoint. Much easier to see now.
Comment: @GoodMorningCaptain Your welcome. I used this fact in my PhD-thesis so I'm very familiar with it. Start with a non-separable ccc linear space. Identify neighbours (points $x < y$ with no point in between) and take the completion (still non-separable and ccc by standard facts). Now the space is connected ordered. Then do this construction as I described and we get a connected and compact ccc non-separable linearly ordered topological space.


struts2. add path to url

Question: I'm working with struts2.
An external app calls to my app with url
http://localhost:8080/present/jsp/mi.action?cod=02021

But because of my JSP file system, my action result is in
http://localhost:8080/present/jsp/ALTE/mi.action?cod=02021

(note the difference in ALTE).
The JSP has some lines as
<%@ include file="../comuns/comunCssyJs.jsp"%>

The first ../ is to go out ALTE.
If I access with first link the page is loaded but no include files are found. However, with second link there is no problem.
Does someone know what can I do? I know I can change my JSP-s dir-s, but I'd prefer to "add automatically" the ALTE path to the url. is that possible?
Thanks in advance.
Jon
Comment: Put an absolute path to `comunCssyJs.jsp` like `/WEB-INF/ALTE/comuns/comunCssyJs.jsp`.
Comment: Wow, that does actually work?
Answer: Use Struts2 <s:include> tag http://struts.apache.org/2.x/docs/include.html with <s:url> tag http://struts.apache.org/2.x/docs/url.html.

struts2. add path to url


Predicted probabilities of square term in Stata

Question: I am estimating a multivariate logit model.
I have included a square term on my main independent variable, IDV and IDV:IDV. And of course a set of control variables.
The results indicate an inverted U shaped relationship; IDV is positive, while IDV:IDV is negative.
I have graphed the probabilities using -postgr3-:
postgr3 IDV, asis(IDV IDV*IDV)

However, I am unsure about how to get the probabilities of different values of IDV.
To be clear, I am looking for something similar to the information -clarify- gives, i.e. the probabilities for different percentiles of my IDV, while taking into account the squared term.
Any ideas? It would be very much appreciated. Let me know if I my question is not clear. I recently started using Stata.
Answer: I am unfortunately unfamiliar with postgr3 and -clarify-, but I have had a similar problem before and ended up employing a solution used by Andreas Wimmer & Brian Min (2006) (article content unrelated).
Basically it boils down to four steps:

create copies of your control variables.
regress with the copies.
fix the value of the control variable copies for all cases using whatever assumptions you deem appropriate.
use the regression equation to compute predicted values for all cases.

With sorted data this produces a nice distribution of predicted probabilities estimates which can be easily plotted. You can also easily get summary data or run additional statistics on the predicted probabilities.
/*logistic regression, c1, c2, and c3 are controls*/
logit y xlin xsq c1 c2 c3

/*generate graphing copies*/
    gen c1g = c1
    gen c2g = c2
    gen c3g = c3

/*regress on copies, resultis will be idential to above regression*/
    logit y xlin xsq c1g c2g c3g

/*replace copies with fixed values, in this case median values*/
    quietly sum c1, det
    replace c1g = r(p50)
    quietly sum c2, det
    replace c2g = r(p50)
    quietly sum c3, det
    replace c3g = r(p50)

/*generate predicted values*/
    sort xlin
    predict pr, p /*probability*/
    predict logodds, xb
    predict stderr, stdp
    generate lodds_lb = logodds - 1.96*stderr
    generate lodds_ub = logodds + 1.96*stderr
    generate ub_p = exp(lodds_ub)/(1+exp(lodds_ub)) /*upper confidence band*/
    generate lb_p = exp(lodds_lb)/(1+exp(lodds_lb)) /*lower confidence band*/

/* PLOT RESULTS */
        twoway (rarea lb_p ub_p xlin, bcolor(gs14)) ///
        (line pr xlin, clcolor(black) clwidth(medthick)), ///
            xline(0, lp(dash) lc(gs14) lw(thin)) ///
            ylabel(#8, labsize(small)) xlabel(#20, labsize(small)) ///
            ytitle(Predicted probability of y, size(small)) xtitle(x, size(small)) ///
            legend(order(2 "Probability of y" 1 "95% confidence interval") size(small) rows(1)) ///
            graphregion(color(white))


Farbtastic color picker to change the background color of text field input?

Question: I have taken this JS from the field_example module. I am attaching it to a form textfield element so that when a user brings focus to it the Farbtastic color picker widget pops up and allows the user to populate the field with the chosen hexadecimal color code. It works as expected. I was also expecting the background of the field to dynamically match the chosen color like this. However, it does not. In the linked example the text also turns black/white depending on the chosen color. This feature is also present in the color module.
I've tried adding to the code below, but nothing I try works. How can I adapt the JS below to achieve this? Thanks.
JS
/**
 * @file
 * Farbtastic color picker.
 */

/**
 * Show farbtastic colorpicker widget.
 */
(function ($) {
  Drupal.behaviors.my_color_picker = {
    attach: function(context) {

      $(".edit-my-color-picker").live("focus", function(event) {
        var edit_field = this;
        var picker = $(this).closest('div').parent().find(".my-color-picker");

        // Hide all color pickers except this one.
        $(".my-color-picker").hide();
        $(picker).show();
        $.farbtastic(picker, function(color) {
          edit_field.value = color;
        }).setColor(edit_field.value);
      });

    }
  }
})(jQuery);

Form element
'color' => array(
  '#type' => 'textfield',
  '#title' => t('Color'),
  '#size' => 8,
  '#suffix' => '

',
  '#attributes' => array(
    'class' => array(
      'edit-my-color-picker',
    ),
  ),
  '#attached' => array(
    'library' => array(
      array(
        'system',
        'farbtastic',
      ),
    ),
    'js' => array(
      drupal_get_path('module', 'my_module ') . '/color-picker.js',
    ),
  ),
),

Answer: Something like this?
/**
 * Show farbtastic colorpicker widget.
 */
(function ($) {
  Drupal.behaviors.my_color_picker = {
    attach: function(context) {

      $(".edit-my-color-picker", context).on("focus", function(event) {
        var edit_field = $(this);
        var picker = edit_field.closest('div').parent().find(".my-color-picker");

        // Hide all color pickers except this one.
        $(".my-color-picker").hide();
        $(picker).show();
        $.farbtastic(picker, function(color) {
          edit_field.val(color);
          // background color, may need to add # to color.
          $(edit_field).css("background-color", color);
        }).setColor(edit_field.value);
      });

    }
  }
})(jQuery);

Notice I added 'context' to the original selector and changed 'live' to 'on'. Live function is deprecated as of jquery 1.7.
I also changed it so the edit_field variable stores the jquery object.
Drupal does already have a couple of color fields, on of which is HERE
Answer: Here's my solution:
/**
 * @file
 * Farbtastic color picker.
 */

/**
 * Show farbtastic colorpicker widget.
 */
(function ($) {
  Drupal.behaviors.my_color_picker = {
    attach: function(context) {

      $(".edit-my-color-picker").live("focus", function(event) {
        var edit_field = this;
        var picker = $(this).closest('div').parent().find(".my-color-picker");

        // Hide all color pickers except this one.
        $(".my-color-picker").hide();
        $(picker).show();
        $.farbtastic(picker, function(color) {
          edit_field.value = color;
          $(edit_field).css("background-color", color);
          $(edit_field).css("color", $.farbtastic(picker).hsl[2] > 0.5 ? "#000" : "#fff");
        }).setColor(edit_field.value);
      });

    }
  }
})(jQuery);


Proving $A^n=\left[\begin{smallmatrix}1&(2^n-1)a\\0&2^n\end{smallmatrix}\right]$

Question:
Given the matrix
  \begin{align}
A = \begin{bmatrix}1&a\\0&2\end{bmatrix} ,
\end{align}
  is it true that
  \begin{align}
A^n=\begin{bmatrix}1&(2^n-1)a\\0&2^n\end{bmatrix}
\end{align}
  for all $n \geq 0$?

I found out that $A^2 = \begin{bmatrix}1 & 3a\\ 0&4 \end{bmatrix}$ and that $A^3 = \begin{bmatrix}1 & 7a\\ 0&8 \end{bmatrix}$, which means that my conjecture holds for small $n$. But I do not know how to prove it in general.
Comment: By induction...
Comment: Welcome to MSE. In the future please include your own thoughts, the effort made so far, and the specific difficulties that got you stuck.
Answer: You can prove this by mathematical induction.
Base:
$$\begin{bmatrix}1&a\\0&2\end{bmatrix} = \begin{bmatrix}1&(2^1-1)a\\0&2^1\end{bmatrix}$$
Induction step:
Suppose $A^n = \begin{bmatrix}1&(2^n-1)a\\0&2^n\end{bmatrix}$. Then $$A^{n + 1} = A^nA = \begin{bmatrix}1&(2^n-1)a\\0&2^n\end{bmatrix}\begin{bmatrix}1&a\\0&2\end{bmatrix} = \begin{bmatrix}1&a + 2(2^n-1)a\\0&2^{n + 1}\end{bmatrix} = \begin{bmatrix}1&(2^{n+1}-1)a\\0&2^{n+1}\end{bmatrix}$$
Comment: The idea behind this proof is that the expression holds true for n=1, and for every n that it holds true, it still does for n+1. Therefore the expression is valid for n=1, therefore for n=2, therefore for n=3 and so on...
Answer: Note that
$$A^n=\left(
I+
\begin{bmatrix}0&a\\0&1\end{bmatrix}
\right)^n=I+\sum_{k=1}^n\binom{n}{k}\begin{bmatrix}0&a\\0&1\end{bmatrix}^k=
I+(2^n-1)\begin{bmatrix}0&a\\0&1\end{bmatrix}=\begin{bmatrix}1&(2^n-1)a\\0&2^n\end{bmatrix}$$
where we used the fact that $\begin{bmatrix}0&a\\0&1\end{bmatrix}^k=\begin{bmatrix}0&a\\0&1\end{bmatrix}$ and $\sum_{k=1}^n\binom{n}{k}=2^n-1$.
Answer: $A$'s characteristic equation is $\lambda^2 -3\lambda +2=0$, whose roots are $1$ and $2$.
Hence, $A^n=B+2^n\cdot C$,where $B$ and $C$ are some matrices that you will find by substituting $n=0$ and $n=1$ into this relation.
Note: This is a method that works for any $2 \times 2$ matrix provided that the computations do not get messy.


Finding coordinates of a vertex in a triangle (vectors)

Question: The problem is the following: We have a triangle ABS with $AB = 4, AC = 5$, and $\angle B =90$ degrees. Place the triangle in a coordinate system with A and C on the first axis symmetric about the origin with A being to the right of C,and B above the x-axis. We can see that $A = (\frac{5}{2}, 0) , C = (\frac{-5}{2}, 0)$.  The problem is to show that $B = (\frac{-7}{10}, \frac{12}{5})$?
I have tried to find B by evaluating the length as the vectors but that does not give me any answer. I have also tried to find B by looking at the vector OB but that does not give me anything. I have also tried to use parametrization, but I dont get any solution. Please help :)
Answer: Hete let us consider B(x,y). So we know AB=$4$ so by distance formula $(x-\frac{5}{2}^2+y^2=16$  also by pythaoras theorem BC=$3$ so again $(x+\frac{5}{2})^2+y^2=9$ so now you have two equations thus you can solve for $x,y$ . Hope you can do the rest!
Comment: @ Eirik Your welcome.
Answer: Let $D$ be a point on the $x$-axis such that $BD$ is perpendicular to the $x$-axis.
Since $\triangle{ABC}$ and $\triangle{ADB}$ are similar, you can have
$$AC:AB=BC:DB$$
to get $DB$.
Comment: Nice trick. Thank you so much :)


Dynamic Pivotting in PostgreSQL

Question: I'd like get a count of every possible value from one table associated with each possible value from another table. So if my (combined) table basically look like:
Order ID     Employee      Product Category
-------------------------------------------
1             Alan          Automobile
2             Barry         Beauty
3             Charlie       Clothing
4             Alan          Beauty

I would like to be able to query and get a result of:
Employee     Count Auto     Count Beauty     Count Clothing
------------------------------------------------------------
Alan         1              1                0
Barry        0              1                0
Charlie      0              0                1

I could manually query for each count, but then if I later add new product categories, it will no longer work. What I'm doing now is basically just:
SELECT employee, category, COUNT(*) FROM sales GROUP BY employee, category;

Which returns:
Employee     Category     Count
-------------------------------
Alan         Automobile   1
Alan         Beauty       1
Alan         Clothing     0

etc. But with a large number of categories this can get a bit redundant. Is there any way to have it returned as a single row for each employee with a column for every category?
Comment: Can the "count" be more than 1? Would really seem like a boolean flag? (In which case, there is a faster way). Also, do you query for a single employee or for all at once?
Comment: Yes, the count will almost always be more than 1. It's querying for all at once to see the total number of items each employee has sold in each category.
Comment: Would two arrays (categories, counts) or one 2-dimensional array or a JSON document per employee do the job, too? Those are all possible without dynamic SQL ...
Comment: So please clarify: do you need distinct columns in the result or are you happy with the JSON document demonstrated by Derviş.
Answer: You can use JSON approach
SELECT employee,
  json_object_agg(ProductCategory,total ORDER BY ProductCategory)
FROM (
 SELECT employee, ProductCategory, count(*) AS total
    FROM tbl
    GROUP BY employee,ProductCategory
) s
GROUP BY employee
ORDER BY employee;

or with two step approach
CREATE FUNCTION dynamic_pivot(central_query text, headers_query text)
 RETURNS refcursor AS
$$
DECLARE
  left_column text;
  header_column text;
  value_column text;
  h_value text;
  headers_clause text;
  query text;
  j json;
  r record;
  curs refcursor;
  i int:=1;
BEGIN
  -- find the column names of the source query
  EXECUTE 'select row_to_json(_r.*) from (' ||  central_query || ') AS _r' into j;
  FOR r in SELECT * FROM json_each_text(j)
  LOOP
    IF (i=1) THEN left_column := r.key;
      ELSEIF (i=2) THEN header_column := r.key;
      ELSEIF (i=3) THEN value_column := r.key;
    END IF;
    i := i+1;
  END LOOP;

  --  build the dynamic transposition query (based on the canonical model)
  FOR h_value in EXECUTE headers_query
  LOOP
    headers_clause := concat(headers_clause,
     format(chr(10)||',min(case when %I=%L then %I::text end) as %I',
           header_column,
       h_value,
       value_column,
       h_value ));
  END LOOP;

  query := format('SELECT %I %s FROM (select *,row_number() over() as rn from (%s) AS _c) as _d GROUP BY %I order by min(rn)',
           left_column,
       headers_clause,
       central_query,
       left_column);

  -- open the cursor so the caller can FETCH right away
  OPEN curs FOR execute query;
  RETURN curs;
END
$$ LANGUAGE plpgsql;

then
=> BEGIN;

-- step 1: get the cursor (we let Postgres generate the cursor's name)
=> SELECT dynamic_pivot(
       'SELECT employee,ProductCategory,count(*)
          FROM tbl GROUP BY employee,ProductCategory
          ORDER BY 1',
       'SELECT DISTINCT productCategory FROM tbl ORDER BY 1'
     ) AS cur
     \gset

-- step 2: read the results through the cursor
=> FETCH ALL FROM :"cur";

Reference
Comment: The first query is exactly what I had in mind talking about a JSON document.
Comment: The second version worked great, exactly what I was looking to do. Had to modify it since my categories have spaces in them, but was quick and easy
Comment: Yes, It is super easy and looks sufficient. any modern language can parse it, so it looks like totally usable
Comment: The second query is one of various 2-step techniques - but can be simpler for the case.

Dynamic Pivotting in PostgreSQL


Allow views in childWindow to become key without losing focus on parentWindow

Question: I added a childWindow of a custom subclass of NSWindow to a parentWindow (also a custom subclass of NSWindow). The childWindow has the NSBorderlessWindowMask and canBecomeKeyWindow: is overridden to return YES and canBecomeMainWindow: to return NO.
The childWindow is set to resize with the parentWindow. So I want to create the illusion that the views of the childWindow are part of the parentWindow. The main idea is to arrange the document windows created by the document-based application within a main window to provide a tabbed interface (just like in a browser) to switch between the documents.
My problem is that whenever I click in one of the views of the childWindow, the parentWindow (the main window) looses focus and the traffic light buttons are getting greyed out. This is obviously contrary to what I want to achieve.
I found this answer:
Make NSView in NSPanel first responder without key window status
But even if I override isKeyWindow: (of the main window) to always return YES, the title bar gets greyed out nonetheless when I click into the childWindow.
I also tried to follow this advice:
http://www.cocoabuilder.com/archive/cocoa/143945-non-focused-child-window.html
But I'm not sure what "include the child window in its responder chain just ahead of its nextResponder" means. With canBecomeKeyWindow: to return NO (for the childWindow), the views within the child never can become key and are always greyed out.
Any clue what I am doing wrong?
One addition: Is it possible to make the views in the childWindow FirstResponder without giving the childWindow key-status?
Comment: @PeterHosey: Yes, the document-based application creates windows for each document. It would be extremely difficult to hack the document-based application architecture to make it produce views for each open document. The effort would essentially mean to completely rewrite the document architecture. I would like to avoid that, because it will be error-prone and I would have to implement all the features coming with future OS X versions myself.

I guess it would not be worth the effort. But at the same time I think that a tabbed-based application is a good approach for my program.
Comment: Is there a reason you're not simply using a tab view (with the tabs turned off, if you'd rather use a custom tab-switcher view) to switch amongst the different views?
Comment: You could override `makeWindowControllers` to make a view controller and add its view to the nearest existing window (if there is one) instead.
Comment: @PeterHosey: It is more than that. The whole document architecture expects windows. If I just override makeWindowController, a whole lot of features will break. This can be read in several answers on questions on how to make a single-window-based document application.

I really thought the answer by Abhi Beckert for [this](http://stackoverflow.com/questions/1116886/multiple-documents-in-a-single-window-in-cocoa) question would be useful. But I failed so far. I just can't make views key while their corresponding window isn't. Just passing on events is not enough.
Comment: I'm currently playing with this myself. It looks like what will work is to have the document window borderless with canBecomeKeyWindow:YES and canBecomeMainWindow:NO. The add it as a child window to the parent, and observe resize events to keep them in sync. There's more, I think perhaps isKeyWindow for the parent needs to return YES if the child window is key, but so far it seems to be working.
Comment: @AbhiBeckert: For me (I'm on 10.8.2), the parent window loses it's key status (or better: it is drawn inactive) once I click into the child window, even if isKeyWindow: is overridden for the parent to always return yes. So you can get focused controls within your child window while maintaining an active parent window?
Comment: When I played with it the parent window was the main window, and the child window was the key window (and therefore one of it's views would be first responder). The parent window's title bar was drawn as usual for the "main" window that is not "key" (see Text Edit's document window when a view inside NSFontPanel has first responder). That's as far as I've taken it so far.
Comment: @AbhiBeckert: In text edit, when a view inside NSFontPanel is FirstResponder, the "traffic lights" of the document window are drawn in grey. Are your "traffic lights" remaining colored?
Comment: No, they don't remain coloured for me. I didn't spend much time looking into how to change that... but I suspect it may be possible. I've decided to use a completely different aproach. See MikeTrent's post at http://cocoadev.com/wiki/DocumentBasedAppWithOneWindowForAllDocuments
Answer: I got this working by mimicking the behaviour of NSPopover. On investigation I found that a popover (which uses a private NSPanel subclass "_NSPopoverWindow") believed it was the key & main window, even though it is not the window returned from [NSApp keyWindow].
Create your own custom NSPanel subclass, attach it to the parent window, and then override the following methods as so:
<code>- (BOOL)isKeyWindow {
    return YES;
}

- (BOOL)isMainWindow {
    return YES;
}

- (BOOL)canBecomeKeyWindow {
    return YES;
}

- (BOOL)canBecomeMainWindow {
    return YES;
}

- (void)makeKeyWindow {
    [super makeKeyWindow];
    [self.parentWindow makeKeyWindow];
}
- (void)makeMainWindow {
    [super makeMainWindow];
    [self.parentWindow makeMainWindow];
}
- (void)becomeKeyWindow {
    [super becomeKeyWindow];
}

- (void)becomeMainWindow {
    [super becomeMainWindow];
    [self.parentWindow becomeMainWindow];
}

- (void)resignMainWindow {

}
- (void)resignKeyWindow {

}
</code>


Contextual filter on a path alias

Question: I am trying to create a page view that will display content by Content:Title which is part of the node's URL.
I have 3 content-types: Movies, Books, and TV Shows.
Each content type has a path alias matching the [node:content-type:machine-name]/[node:title]/[current-date:custom:Ymd] pattern.
I successfully created a view called movies with a filter on Movies that displays all the nodes with www.example.com/movies/ in the URL. If I click on a node in the Movies view, it displays the content using the node.tpl.php template file.
I added a contextual filter (Content: Title) using Scott Edmonds suggestion.
Contextual Filter for: Content: Title ). When filter is not in URL -> Provide Default Value -> Raw Value from URL -> Path Component=2. Use Path Alias=Checked. Then, When Filter Value is In URL: Specify Validation Criteria= "PHP Code" with the following PHP code: $handler->argument = str_replace("-"," ",$argument); return true; That did the trick. the PHP code converts the dashes to spaces so it can be evaluated correctly.
The result is that when I click on the "Star Trek is Great" post link I am taken to the correct URL, www.example.com/movies/star-trek-great/20130702,  but node.tpl.php is the template used instead of views-view--movies.tpl.php.
When I copy the title and paste it into the url, as "www.example.com/movies/Star Trek is Great/20130712" the views template page comes us.
Some where along the way I am missing something.  Any help out there?
FYI - I also have simply set the contextual filter on Content:Title with
Display all results for the specified field
Checked "Override title" and added %1 as the first argument
Seleced "lowercase" for the Case PATH
Selected "transform spaces to dashes in url"
But nothing worked :(
Answer: The issue is the following:
When you go to www.example.com/movies/star-trek-great/20130702 Drupal sees that this is a path alias to node/#, and it displays that node.  It won't use Views at all.
When you go to www.example.com/movies/Star Trek is Great/20130712, this does not map to any URL, but rather to the View sitting at www.example.com/movies with an contextual filter of Star Trek is Great (and 20130712 most probably).
You may have some other issues to work out as well:
Pathauto is taking out the is (and other small words by default) so there will be a bit of a hard time mapping star-trek-great to Star Trek is Great.
Also, what happens if you have a title of Star Trek is Great!!! that maps to star-trek-great as well?

Contextual filter on a path alias


ANTLR Warning: TestRig moved to org.antlr.v4.gui.TestRig

Question: I have been trying to get ANTLR to work all day. I have used several websites including antlr.org, numerous StackOverflow queries and the textbook by Terence Parr. I am on a Windows 7 machine (work machine, can't change to Linux) but I have tried this on both CommandPrompt and Cygwin, with the same result.
No matter what I do, when it comes time to use the grun file, I always come up with the same error in the end:

Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
  Can't load Hello as lexer or parser

I have the most recent versions of the JRE and JDK on my computer, as well as the most recent version of cygwin.
I can run the batch files for grun and antlr4 from anywhere, so I'm strongly guessing my path is set correctly. I can run antlr4.bat with absolutely no issue. It creates every file the text book says I should see:
Hello.g4      HelloBaseListener.java  HelloLexer.tokens   HelloParser.java        Hello.tokens  HelloLexer.java         HelloListener.java
I can run javac on those files and it generates various CLASS files:
HelloBaseListener.class   HelloLexer.class   HelloListener.class   HelloParser$RContext.class   HelloParser.class
But then, when I try to run grun on it, I get this:

Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
  Can't load Hello as lexer or parser

I've tried several combinations of commands to use the grun file, but the one it says to use in the book is:
grun.bat Hello r -tree

I've also changed the .bat file with grun several times, just to experiment, using different combinations in the books and on the sites, but I always come back to this:
java org.antlr.v4.runtime.misc.TestRig %*

That is what my boss told me to use, and it works for him.
Comment: Does this help? https://github.com/antlr/antlr4/issues/147
Comment: No. It made no difference. Thank you, though.
Comment: I have the same problem on OS X 10.9.5 and brew install.
added:
export CLASSPATH=".:/usr/local/Cellar/antlr/4.5.1/antlr-4.5.1-complete.jar:$CLASSPATH"

after:
grun Hello r -tokens
Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Answer: Use this in your grun.bat command
java org.antlr.v4.gui.TestRig %*

Answer: I had the same problem, there is actually already a thread with the solution here --> antlr4-Can't load Hello as lexer or parser
The first part of the message "Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically" just means that the TestRig order is saved to another location, it works anyway but I changed my batch data accordingly and did not get the Warning anymore. The second part of the message is the actual problem (see link). In my case I forgot the "." (dot) in my CLASSPATH in Windows.
Comment: It would be helpful if you could paste the answer into your answer - external links are unreliable as could be lost in the future and lose any value for others with the same problem.


Testing for differences between pooled biological samples

Question: I am trying to test for differences in absorbance between a control and treatment group.  Due to cost, each measurement is derived from the mixture of 5 independent samples.  Overall there are 5 sample measurements each derived from 5 individual samples.  The data would look like:
Control:
Measurement 1 (from 5 combined samples)
Measurement 2 (from 5 combined samples)
Measurement 3 (from 5 combined samples)
etc.

Treatment:
Measurement 1 (from 5 combined samples)
Measurement 2 (from 5 combined samples)
Measurement 3 (from 5 combined samples)
etc.

Here my issue is that each measurement would be close to the mean value of the 5 combined samples and we would not know much about the actual variance that would be observed across individual samples.  Because of this I'm thinking that I can't apply a simple test like a t test to test for a difference between groups.
I appreciate any suggestions about how to properly test between the groups using data gathered in this fashion.  Also, would your suggestion work if each measurement was collected from varying numbers of samples?  For example: 3 sample for one measurement, 5 samples for another measurement, 2 samples for another?
Comment: Please clarify what you mean by 'pool'. You say that if $X_{11}, X_{12}, \dots , X_{15}$ are pooled, then the mean of the pooled value $X_1$ is close the the means of the constituent $X_{1j}$s, and that makes me think $X_1$ may be an average. But some of you other statements lead me to guess that pooling isn't just averaging.
Comment: Sorry, I don't mean pooling in the statistical sense.  Equal amounts of material from five separate subjects are physically mixed together and one measurement is taken from that mixture.  This site states that mixing samples can improve precision in the case of transcriptomic data and the measurement will represent the mean of the mixed samples.  However, I am confused because I'm thinking that the observed variance will be underestimated when using mean values as replicates instead of measurements from individual samples. [link](https://online.stat.psu.edu/stat555/node/75/)
Comment: I think you would be safe treating each pooled observation as a data point and running a two-sample test using five 'observations' in each group. Use a Welch t test if pooled observations seem normal, otherwise Wilcoxon rank sum. For these tests, it is the variability of the pooled observations themselves that matters. // See my answer for hypothetical count data below. If you want to post your actual10 pooled data values, I will have a look at them.
Answer: One possibility is that your 50 original samples are Poisson counts, in which case pooling
would give you 10 pooled samples with somewhat larger Poisson counts---five Control and five Treatment.
Poisson data with reasonably large counts are approximately normal. A difficulty might
be that different population means between the Treatment and Control groups would imply different population variances also. There are two ways to handle potentially different variances in this situation. A traditional approach is to use a square root transformation to 'stabilize' variances. Another would be to use a Welch 2-sample t test, which does not require equal variances. I would prefer the latter.
Maybe your data are something like the simulated data below:
set.seed(1126)
x1 = rpois(5, 20)
x2 = rpois(5, 35)
summary(x1); length(x1);  sd(x1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
     16      23      24      23      26      26
[1] 5            # sample size
[1] 4.123106     # sample standard deviation

summary(x2); length(x2);  sd(x2)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   25.0    30.0    35.0    33.2    36.0    40.0
[1] 5
[1] 5.80517

stripchart(list(x1,x2), ylim=c(.5, 2.5), meth="stack", pch=20)

For illustration, here are results from a Welch t test on the counts and a pooled 2-sample t test on square
roots of counts. Both tests find significant differences at the 2% level.
[You should choose one test.]
t.test(x1, x2)

        Welch Two Sample t-test

data:  x1 and x2
t = -3.2032, df = 7.217, p-value = 0.01439
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -17.68411  -2.71589
sample estimates:
mean of x mean of y
     23.0      33.2

t.test(sqrt(x1), sqrt(x2), var.eq=T)

         Two Sample t-test

data:  sqrt(x1) and sqrt(x2)
t = -3.1448, df = 8, p-value = 0.01371
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.6726184 -0.2573859
sample estimates:
mean of x mean of y
 4.778570  5.743572

Notes: (1) For the test on square roots of counts, the confidence interval may be difficult to
interpret. (2) If any counts are $0,$ it is customary to add $0.5$ to all
counts before taking square roots.
Comment: Thank you very much!  I was leaning towards Welch's t-test which I would have used if the measurements were taken from single individual samples.  I was mainly hung up about whether measurements from the physically mixed samples would cause the test to be too permissive.


Proof that diffusion-"reaction" equations yield a non-negative solution

Question: First question: I wish to prove that there exists a unique, positive solution $\phi_g(x,t)$ to the following system of $G$ PDEs with initial and boundary conditions for $t \ge 0$, $0 \le x \le X$:
$$ \left[\frac{1}{v_g}\frac{\partial}{\partial t} - \frac{\partial}{\partial x} D_g(x) \frac{\partial}{\partial x} \right] \phi_g(x,t) + \sum_{g'=1}^G \Sigma_{r, g' \to g}(x) \phi_{g'}(x,t) = 0 $$
$$ \phi_g(x,0) = \phi_{g,0}(x) > 0$$
$$ \phi_g(0,t) - 2 D_g(0) \frac{\partial\phi_g}{\partial x}(0,t) = 0 $$
$$ \phi_g(X,t) + 2 D_g(X) \frac{\partial\phi_g}{\partial x}(X,t) = 0 $$
Here, $v_g, D_g(x) > 0$ for all $g$, $\Sigma_{r, g' \to g}(x) \ge 0$ when $g = g'$, and $\Sigma_{r, g' \to g}(x) \le 0$ when $g \ne g'$.
Basically, I want to show $\phi_g(x,t) > 0$ for all $g$ and for all $x,t$ in my domain.  Proving uniqueness/existence would be nice, but positivity/non-negativity is the thing I'm most interested in.  From physical intuition (and from having solved these problems for a variety of physical parameters), I'm fairly confident that there must exist a unique, positive solution.  However, I have no idea how to prove it.  If you have any thoughts on how I could approach this proof, or know of a good reference that might lead me to such a proof, I would be very grateful!!
In Hundsdorfer's "Numerical Solution of Time-Dependent Advection-Diffusion-Reaction Equations" book, this is touched on a little bit in Chapter 1 (sections 1 and 7), but he only explicitly proves things for problems in which there is no dependence on $x$.
(Side note: In my field of study, this is the neutron diffusion equation, but I've seen in literature that it's more commonly referred to in the chemistry setting as diffusion-reaction equations, so I'm using that name here in hopes of drawing more attention.)
EDIT: Sorry, I had a small typo describing the positivity/negativity of the physical parameters.  Fixed now.
EDIT2: Made it more clear which parameters are space-dependent.
EDIT3: Altered the initial condition a bit to make it easier.  We also have the following inequality:
$$ \sum_{g'=1}^G \Sigma_{r,g \to g'} \ge 0 $$
I think I have a rough proof for my first question, which I will post as an answer shortly, but now I also have a new, related question.
==========================================================================
New, related question: Can we show that the corresponding BVP
$$- \frac{\partial}{\partial x} D_g(x) \frac{\partial}{\partial x}  \phi_g(x) + \sum_{g'=1}^G \Sigma_{r, g' \to g}(x) \phi_{g'}(x) = q_g(x) $$
$$ \phi_g(0) - 2 D_g(0) \frac{\partial\phi_g}{\partial x}(0) = 0 $$
$$ \phi_g(X) + 2 D_g(X) \frac{\partial\phi_g}{\partial x}(X) = 0 $$
has a "positive" solution?  i.e., can we show that $\phi_g(x) > 0$ for all $x \in [0,X]$?  Here, $q_g(x)$ is a "positive" source.  That is, $q_g(x) \ge 0$ and
$$ \sum_g \int_0^X q_g(x) dx > 0 $$
Answer: Here's my first attempt at a proof of the positivity (with lots of help from a friend).  I think there are some "holes" in it, and I would appreciate any feedback on what those holes are and how to fill them in.
First, we note that $\phi_g(x,t)$, for any $g$, cannot have a negative minimum at $x = 0$ or $x=t$ -- the boundary conditions indicate that, if $\phi_g(0,t) < 0$ or $\phi_g(X,t) < 0$, then $\phi_g(x,t)$ is decreasing "into" the domain.  Thus, we can assume that, if there are any negative components to $\phi_g(x,t)$, the global minimum would occur at an interior location (i.e., not at $x = 0$ or $x = X$).
We note that at time $t = 0$, everything is positive.  Let $t_0$ denote the first time at which one (or more) of the $\phi_g(x,t)$ functions become zero-valued at some point $x_0$. Let $g_0$ be the index of that function.  $x_0$ is a global minimum point of $\phi_{g_0}(x,t_0)$.  Thus, at this time and at this point in space, the following must be true:
$$ \phi_{g_0}(x_0,t_0)  = 0 $$
$$ \phi_g(x_0,t_0) \ge 0 $$
$$ \frac{\partial}{\partial x} \phi_{g_0}(x_0,t_0)  = 0 $$
$$ \frac{\partial^2}{\partial x^2} \phi_{g_0}(x_0,t_0) > 0 $$
Moreover, since it has just decreased to zero,
$$ \frac{\partial}{\partial t} \phi_{g_0}(x_0,t_0) \le 0 $$
Now, we revisit the terms of the PDE.  The time derivative is $\le 0$.  The spatial derivative term is strictly negative due to the negative sign and the strict positivity of the second derivative.  The sum over $g'$ is negative unless all of the $\phi_g(x_0,t_0)$'s are zero; in that case, it is equal to zero.
Thus, we have something negative on the left hand side equal to zero on the right hand side.  This is a contradiction -- our assumption that one of the $\phi_g(x,t)$'s become zero-valued at some point is impossible.
The one case I think this proof/argument leaves out is what if all the $\phi_g(x,t)$ becomes identically zero for all $x$ at time $t = t_0$.  $\phi_g(x,t) = 0$ is a steady state solution for this problem as $t \to \infty$.  However, I feel like this is impossible as long as we have a positive initial condition and $t$ is finite.  Not sure how to show this explicitly though, I'll have to give it some more thought.


same song in B major and B minor

Question: This song I'm learning to play-Flower Dance by DJ Okawari-is in B minor in one version and B major in another version. I don't know much at all about transposing and changing a song from a different key so I'm a bit confused. It doesn't sound that different to me, but how much of a difference in sound will this make? Sorry if this is confusing.
This is the sheet music I'm learning from (from Musescore.com):

But there are other versions at https://musescore.com/user/102470/scores/171373 and https://musescore.com/user/7745406/scores/4417756 that are in B Major.
Comment: Minor vs. major is no transposition task. Most likely, the song becomes a different one in the process.
Answer: Actually, both of the versions you posted in the comments are in a major key; the first one is in B-flat major, the second one in B major. Hence, there is a one-semitone difference between the two. This doesn't make that much of a difference on how the song will "sound" nowadays, so choosing between them is basically a matter of how easy it is for you to read the score and play it on your instrument. (People tend to have a hard time when there are many accidentals in the key signature, so the B-flat major version is probably the safest option.)
Edit. Thanks for the comment @Dekkadeci, I had not read the scores carefully enough. Substitute every instance of B-flat major above with G minor and every instance of B major with G-sharp minor. The pertinence and meaning of my answer remain unchanged.
Comment: Based on the accidentals, the first example is actually in G minor and the second 2 examples are in G sharp minor.
Answer: The G minor version has fewer mistakes than the other versions, which have been prepared by someone with little skill in music or in notation software:

It's hard to tell which version came first, but on a violin the G minor version will obviously sound richer and more resonant than the G#m version, the string-lengths being greater than if you play it a semitone higher.
Have you got an accompaniment for the G minor version? It is rather short of expression markings, isn't it? But what bowing there is is OK. Bar seven is wrongly notated: the tied A's should just be a regular quaver.
Comment: This does not directly address the OP's question. It would be better as a comment.
Comment: @Peter The question was "how much of a difference in sound will this make?" My answer was "the G minor version will sound richer than the G#m version: more resonant." I feel that directly addresses the OP's question. Please tell me why you say it doesn't. I also corrected him (and the earlier answer) in describing the piece as being in a major key. It is in a minor key. The only keys involved are therefore Gm and G#m. He said he was confused, so I tried to suggest he stick with the version above rather than the other versions he linked to which are hard to decypher. Did you look at them?
Comment: @Peter I'm hoping for a reply.
Comment: Your answer mostly involves criticizing the arranger of the music. The part about being more resonant is buried in the middle, and you offer no reason or explanation for it. You need to say why it's more resonant.
Comment: @Peter Where did I mentioned an arranger? I said "**prepared** by someone with little skill in music or in notation software." You didn't say if you'd looked at the other versions, so I've added a scan to my answer. Please look at it and tell me whether you disagree with my remarks about its preparation. The OP said, " I'm a bit confused" so I tried to steer him/her *away* from that confusing G#m version. Wouldn't *you* have done that? I've added a reason why it'd be more resonant. It seemed obvious: long strings resonate longer than short ones."Buried in the middle"?? Of seven lines?!!

same song in B major and B minor


Semi-Fancy Regex.Replace() function

Question: Words placed after these punctuation marks must be capitalized (note that there may be spaces or special characters on either side of these when used):
dash ( - ), slash ( / ), colon ( : ), period ( . ), question mark ( ? ), exclamation
point ( ! ), ellipsis (... OR …) (they are different)
I am sort of bogged down on this puzzle because of all of the special regex characters that I am trying to literally look for in my search. I believe I can use Regex.Escape although I cannot get it working for me right now in this case.
A few examples of starting strings to change to might be:
Change this:
This is a dash - example
To this:
This is a dash - Example       <--capitalize "Example" with Regex

This is another dash -example
This is another dash -Example

This is an ellipsis ... example
This is an ellipsis ... Example

This is another ellipsis …example
This is another ellipsis …Example

This is a slash / example
This is a slash / Example

This is a question mark ? example
This is a question mark ? Example

Here is the code I have so far:
private static string[] postCaps = { "-", "/", ":", "?", "!", "...", "…"};
private static string ReplacePostCaps(string strString)
{

    foreach (string postCap in postCaps)
    {

        strString = Regex.Replace(strString, Regex.Escape(postCap), "/(?<=(" + Regex.Escape(postCap) + "))./", RegexOptions.IgnoreCase);

    }
    return strString;

}

Thank you very much!
Comment: Please show your code.
Comment: To capitalize, you will need the version of the Regex.Replace() method where it has a replacement callback.
Comment: Spend a few hours going through this tutorial: http://www.regular-expressions.info/tutorial.html it's heavy going in places but goes into detail about what the regex engine is actually doing with the pattern.
Comment: Why do you use a regex at all? The task can be done by a simple string.Replace()
Comment: I added my example code. @TomB you may be onto something there. Good point. Can you elaborate? I know what the characters I am looking for are, of course. But I do not know if they are followed by a space or not and I do not know what the word after that will be, but I know I want to capitalize that word.
Answer: You shouldn't need to iterate over a list of punctuation but instead could just add a character set in a single regex:
(?:[/:?!…-]|\.\.\.)\s*([a-z])

To use it with Regex.Replace():
strString = Regex.Replace(
    strString,
    @"(?:[/:?!…-]|\.\.\.)\s*([a-z])",
    m => m.ToString().ToUpper()
);

Regex Explained:
(?:                 # non-capture set
    [/:?!…-]        # match any of these characters
    | \.\.\.        # *or* match three `.` characters in a row
)
\s*                 # allow any whitespace between matched character and letter
([a-z])             # match, and capture, a single lowercase character

Answer: Maybe this works for you:
var phrase = "This is another dash ... example";
var rx = new System.Text.RegularExpressions.Regex(@"(?<=[\-./:?!]) *\w");
var newString = rx.Replace(phrase, new System.Text.RegularExpressions.MatchEvaluator(m => m.Value.ToUpperInvariant()));

Semi-Fancy Regex.Replace() function


How to determine if my Yamaha guitar is an original?

Question: I recently purchased this guitar is original? The model is Yamaha SG510.
How can I determine if my newly purchased guitar is original?
Comment: I don't know squat about guitars, but as far as I know, the Y from the Yamaha logo never look like that. I'd say "fake".
Comment: The tuners seem to be misaligned too, not a good sign.
Answer: I grabbed a dozen or so Google Images and none look even close.  All the SG510 heads have a big logo and different font as Edouard pointed out.
Unless your axe was heavily, and badly, refinished, you're stuck.


G-WAN: "no listener" error after installation on Ubuntu Server 14.04 with XFS filesystem

Question: I'm desperately trying to start G-WAN since two days without any progress, so please let me now ask for your gentle help because I'm becoming (more) crazy !
Here is the log after a start with ./gwan -d -w 1
<code>[Sun Jan 10 13:32:58 2016 GMT] ------------------------------------------------
[Sun Jan 10 13:32:58 2016 GMT] G-WAN 4.3.14 64-bit (Mar 14 2013 07:33:12)
[Sun Jan 10 13:32:58 2016 GMT] ------------------------------------------------
[Sun Jan 10 13:32:58 2016 GMT] Local Time: Sun, 10 Jan 2016 14:32:58 GMT+1
[Sun Jan 10 13:32:58 2016 GMT] RAM: (7.27 GiB free + 0 shared + 704.00 KiB buffers) / 7.84 GiB total
[Sun Jan 10 13:32:58 2016 GMT] Physical Pages: 7.27 GiB / 7.84 GiB
[Sun Jan 10 13:32:58 2016 GMT] DISK: 115.94 GiB free / 118.47 GiB total
[Sun Jan 10 13:32:58 2016 GMT]  Filesystem     Type      Size  Used Avail Use% Mounted on
[Sun Jan 10 13:32:58 2016 GMT]  udev           devtmpfs  3.9G  4.0K  3.9G   1% /dev
[Sun Jan 10 13:32:58 2016 GMT]  tmpfs          tmpfs     798M  468K  797M   1% /run
[Sun Jan 10 13:32:58 2016 GMT]  /dev/sda2      xfs       119G  2.2G  116G   2% /
[Sun Jan 10 13:32:58 2016 GMT]  none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup
[Sun Jan 10 13:32:58 2016 GMT]  none           tmpfs     5.0M     0  5.0M   0% /run/lock
[Sun Jan 10 13:32:58 2016 GMT]  none           tmpfs     3.9G     0  3.9G   0% /run/shm
[Sun Jan 10 13:32:58 2016 GMT]  none           tmpfs     100M     0  100M   0% /run/user
[Sun Jan 10 13:32:58 2016 GMT]  /dev/sda1      xfs       186M   46M  141M  25% /boot
[Sun Jan 10 13:32:58 2016 GMT] 162 processes, including pid:5280 './gwan -d -w 1'
[Sun Jan 10 13:32:58 2016 GMT] Page-size:4,096 Child-max:63,605 Stream-max:16
[Sun Jan 10 13:32:58 2016 GMT] CPU: 1x Intel(R) Atom(TM) CPU C2750 @ 2.40GHz
[Sun Jan 10 13:32:58 2016 GMT]  0 id: 0     0
[Sun Jan 10 13:32:58 2016 GMT]  1 id: 1     1
[Sun Jan 10 13:32:58 2016 GMT]  2 id: 2     2
[Sun Jan 10 13:32:58 2016 GMT]  3 id: 3     3
[Sun Jan 10 13:32:58 2016 GMT]  4 id: 4     4
[Sun Jan 10 13:32:58 2016 GMT]  5 id: 5     5
[Sun Jan 10 13:32:58 2016 GMT]  6 id: 6     6
[Sun Jan 10 13:32:58 2016 GMT]  7 id: 7     7
[Sun Jan 10 13:32:58 2016 GMT] Cores: possible:0-7 present:0-7 online:0-7
[Sun Jan 10 13:32:58 2016 GMT] L1d cache:   24K line:64     0
[Sun Jan 10 13:32:58 2016 GMT] L1i cache:   32K line:64     0
[Sun Jan 10 13:32:58 2016 GMT] L2  cache: 1024K line:64   0-1
[Sun Jan 10 13:32:58 2016 GMT] NUMA node #1 0-7
[Sun Jan 10 13:32:58 2016 GMT] CPU(s):1, Core(s)/CPU:4, Thread(s)/Core:2
[Sun Jan 10 13:32:58 2016 GMT] Bogomips: 4,800.19
[Sun Jan 10 13:32:58 2016 GMT] Virtualization: VT-x
[Sun Jan 10 13:32:58 2016 GMT] './gwan -w 1' used to override 1 x 4-Core CPU(s)
[Sun Jan 10 13:32:58 2016 GMT]   using   1 workers 0[00000001]0
[Sun Jan 10 13:32:58 2016 GMT]   among   8 threads 0[11111111]7
[Sun Jan 10 13:32:58 2016 GMT] 64-bit little-endian (least significant byte first)
[Sun Jan 10 13:32:58 2016 GMT] Ubuntu 14.04.3 LTS \n \l (3.13.0-74) 64-bit
[Sun Jan 10 13:32:58 2016 GMT] user: root (uid:0), group: root (uid:0), members: lm4ppdcd
[Sun Jan 10 13:32:58 2016 GMT] system  fd_max: 1,024
[Sun Jan 10 13:32:58 2016 GMT] program fd_max: 1,024
[Sun Jan 10 13:32:58 2016 GMT] updated fd_max: 500,000
[Sun Jan 10 13:32:58 2016 GMT] Available network interfaces (2):
[Sun Jan 10 13:32:58 2016 GMT] 127.0.0.1
[Sun Jan 10 13:32:58 2016 GMT] 188.8.131.52
[Sun Jan 10 13:32:58 2016 GMT] * no listener in /opt/gwan64

[Sun, 10 Jan 2016 13:32:58 GMT] * child normal exit(1)

[Sun Jan 10 13:32:58 2016 GMT] * no listener in /opt/gwan64

[Sun, 10 Jan 2016 13:32:58 GMT] * child normal exit(1)

[Sun Jan 10 13:32:58 2016 GMT] * no listener in /opt/gwan64

[Sun, 10 Jan 2016 13:32:58 GMT] * child normal exit(1)

[Sun Jan 10 13:32:58 2016 GMT] * no listener in /opt/gwan64

[Sun, 10 Jan 2016 13:32:58 GMT] * child died 3 times within 3 seconds
</code>
I've turned all files and directories under gwan64 to 777 and all of them are now owned by root in the root group.
I've changed the active interface from em1 to eth0 too !
Thanks in advance for your guidance to solve this problem encountered on my new server and kind regards, email@example.com
Hi Law29, here is the result of ls -ltrR /opt/gwan64
<code>  /opt/gwan64:
  total 220
  drwxrwxrwx 2 root root     21 Aug 13  2011 fonts
  -rwxrwxrwx 1 root root   5619 Aug 13  2011 license.txt
  -rwxrwxrwx 1 root root    877 Dec 21  2011 hello.c
  -rwxrwxrwx 1 root root   3138 Jan  6  2012 readme.txt
  -rwxrwxrwx 1 root root   1056 Jan 18  2012 argv.c
  -rwxrwxrwx 1 root root   1322 Jan 27  2012 main.c__
  drwxrwxrwx 6 root root     56 Dec 25  2012 libraries
  drwxrwxrwx 2 root root   4096 Mar 10  2013 include
  -rwxrwxrwx 1 root root 188152 Mar 14  2013 gwan
  drwxrwxrwx 3 root root     28 Jan  9 18:09 18.104.22.168_80
  drwxrwxrwx 2 root root     47 Jan 10 14:32 logs
  -rw-r--r-- 1 root root      0 Jan 10 14:32 gwan_05280.pid
  -rw-r--r-- 1 root root      0 Jan 10 14:32 gwan_05286.pid
  -rw-r--r-- 1 root root      0 Jan 10 14:32 gwan_05290.pid
  -rw-r--r-- 1 root root      0 Jan 10 14:32 gwan_05294.pid
  -rw-rw-rw- 1 root root      0 Jan 10 14:32 Gwan_05279.pid
  -rw-rw-rw- 1 root root   6424 Jan 10 14:32 trace

  /opt/gwan64/fonts:
  total 4
  -rwxrwxrwx 1 root root 576 Jul 29  2010 9pts.gif

  /opt/gwan64/libraries:
  total 0
  drwxrwxrwx 3 root root 16 Feb 23  2012 java
  drwxrwxrwx 2 root root 24 Sep  6  2012 cs
  drwxrwxrwx 2 root root 49 Oct  8  2012 tkcabinet
  drwxrwxrwx 2 root root 41 Oct  8  2012 sqlite3

  /opt/gwan64/libraries/java:
  total 0
  drwxrwxrwx 2 root root 39 Oct  8  2012 api

  /opt/gwan64/libraries/java/api:
  total 8
  -rwxrwxrwx 1 root root 370 Feb 23  2012 Gwan.class
  -rwxrwxrwx 1 root root 874 Aug 28  2012 Gwan.java

  /opt/gwan64/libraries/cs:
  total 4
  -rwxrwxrwx 1 root root 1501 Sep  6  2012 gwan_api.cs

  /opt/gwan64/libraries/tkcabinet:
  total 320
  -rwxrwxrwx 1 root root 190377 Aug  5  2010 tcutil.h
  -rwxrwxrwx 1 root root  45754 Aug  5  2010 tchdb.h
  -rwxrwxrwx 1 root root  82844 Aug  5  2010 tcfdb.c

  /opt/gwan64/libraries/sqlite3:
  total 288
  -rwxrwxrwx 1 root root  20686 Dec  8  2009 sqlite3ext.h
  -rwxrwxrwx 1 root root 268351 Feb  3  2010 sqlite3.h

  /opt/gwan64/include:
  total 112
  -rwxrwxrwx 1 root root  1149 Jan  6  2012 short_types.h
  -rwxrwxrwx 1 root root  4545 Jan 31  2012 xbuffer.h
  -rwxrwxrwx 1 root root  2968 Jun 19  2012 fastcgi.h
  -rwxrwxrwx 1 root root  1530 Jan 10  2013 float.h
  -rwxrwxrwx 1 root root   356 Jan 10  2013 varargs.h
  -rwxrwxrwx 1 root root   545 Jan 10  2013 stddef.h
  -rwxrwxrwx 1 root root   180 Jan 10  2013 stdbool.h
  -rwxrwxrwx 1 root root   401 Jan 10  2013 stdarg.h
  -rwxrwxrwx 1 root root 27140 Feb 19  2013 gwdbg.h
  -rwxrwxrwx 1 root root 46307 Mar 10  2013 gwan.h

  /opt/gwan64/126.96.36.199_80:
  total 0
  drwxrwxrwx 7 root root 64 Jan  3  2013 #126.96.36.199

  /opt/gwan64/22.214.171.124_80/#18.104.22.168:
  total 4
  drwxrwxrwx 2 root root    6 Jan 27  2012 _logs
  drwxrwxrwx 2 root root    6 Apr 20  2012 gzip
  drwxrwxrwx 2 root root  124 Jan  3  2013 handlers
  drwxrwxrwx 3 root root 4096 Mar  8  2013 csp
  drwxrwxrwx 3 root root  135 Mar 14  2013 www

  /opt/gwan64/220.127.116.11_80/#22.214.171.124/_logs:
  total 0

  /opt/gwan64/22.214.171.124_80/#126.96.36.199/gzip:
  total 0

  /opt/gwan64/188.8.131.52_80/#220.127.116.11/handlers:
  total 36
  -rwxrwxrwx 1 root root  783 Mar  3  2012 html.c_
  -rwxrwxrwx 1 root root 2057 May  4  2012 flv.c_
  -rwxrwxrwx 1 root root 9789 May  4  2012 main_generic.c_
  -rwxrwxrwx 1 root root 3744 May  4  2012 main_hello.c_
  -rwxrwxrwx 1 root root 7226 May  4  2012 main_404_redirect.c_
  -rwxrwxrwx 1 root root 2136 May  4  2012 main_restful.c_

  /opt/gwan64/18.104.22.168_80/#126.96.36.199/csp:
  total 592
  -rwxrwxrwx 1 root root  1292 Dec  6  2010 argv.c
  -rwxrwxrwx 1 root root  2791 Jul  4  2011 report.c
  -rwxrwxrwx 1 root root  1727 Nov 28  2011 trace.c
  -rwxrwxrwx 1 root root  8329 Nov 28  2011 captcha.c
  -rwxrwxrwx 1 root root  6674 Nov 28  2011 data_uri.c
  -rwxrwxrwx 1 root root   963 Nov 29  2011 exit.c
  -rwxrwxrwx 1 root root  3125 Dec 17  2011 crash_libc.c
  -rwxrwxrwx 1 root root  2384 Dec 17  2011 crash.c
  -rwxrwxrwx 1 root root  1470 Dec 17  2011 asm.c
  -rwxrwxrwx 1 root root  3153 Dec 21  2011 crash_gwcall.c
  -rwxrwxrwx 1 root root  2180 Dec 27  2011 email.c
  -rwxrwxrwx 1 root root  1672 Dec 27  2011 div_by_zero.c
  -rwxrwxrwx 1 root root   898 Dec 31  2011 servlet_name.c
  -rwxrwxrwx 1 root root  1605 Dec 31  2011 sql.c_
  -rwxrwxrwx 1 root root  1418 Jan  6  2012 redirect.c
  -rwxrwxrwx 1 root root  1706 Jan  8  2012 hello.m_
  -rwxrwxrwx 1 root root  1755 Jan  8  2012 hello.mm_
  -rwxrwxrwx 1 root root  2848 Jan  8  2012 gnustep.m__
  -rwxrwxrwx 1 root root  1038 Jan 15  2012 100.c
  -rwxrwxrwx 1 root root  2187 Jan 15  2012 base64.c
  drwxrwxrwx 2 root root    48 Jan 15  2012 folder
  -rwxrwxrwx 1 root root 23428 Jan 16  2012 sqlite.c_
  -rwxrwxrwx 1 root root 53260 Jan 27  2012 kv_bench.c_
  -rwxrwxrwx 1 root root   882 Jan 27  2012 www_csp.c
  -rwxrwxrwx 1 root root  2070 Jan 30  2012 rates.xml
  -rwxrwxrwx 1 root root   802 Feb 23  2012 report.java
  -rwxrwxrwx 1 root root 10387 Feb 25  2012 charts.c
  -rwxrwxrwx 1 root root  1293 Mar  4  2012 all.java
  -rwxrwxrwx 1 root root  6759 Mar  5  2012 getheaders.c
  -rwxrwxrwx 1 root root  8096 Mar  5  2012 forum.c
  -rwxrwxrwx 1 root root  1414 Mar  5  2012 argv.java
  -rwxrwxrwx 1 root root  2516 Mar 10  2012 bigtable.c
  -rwxrwxrwx 1 root root  1126 Mar 18  2012 power.c
  -rwxrwxrwx 1 root root  1457 Mar 21  2012 cache.c
  -rwxrwxrwx 1 root root 20943 Mar 29  2012 json.c
  -rwxrwxrwx 1 root root 19191 Apr 11  2012 kv.c
  -rwxrwxrwx 1 root root 11911 Apr 22  2012 loan.java
  -rwxrwxrwx 1 root root  2960 Aug 29  2012 cairo.c_
  -rwxrwxrwx 1 root root 11074 Sep 12  2012 comet.c
  -rwxrwxrwx 1 root root  7090 Sep 14  2012 contact.c
  -rwxrwxrwx 1 root root  1423 Sep 15  2012 hellox.c
  -rwxrwxrwx 1 root root 14838 Sep 16  2012 chart.c
  -rwxrwxrwx 1 root root 12005 Sep 16  2012 request.c
  -rwxrwxrwx 1 root root  2915 Sep 16  2012 curl.c_
  -rwxrwxrwx 1 root root  5933 Sep 16  2012 httpdate.c
  -rwxrwxrwx 1 root root 12693 Oct  6  2012 fractal.c
  -rwxrwxrwx 1 root root  7862 Oct 18  2012 served_from.c
  -rwxrwxrwx 1 root root  2487 Nov 22  2012 persistence.c
  -rwxrwxrwx 1 root root  6186 Dec  8  2012 tidy.c_
  -rwxrwxrwx 1 root root  2565 Dec 10  2012 hello.go
  -rwxrwxrwx 1 root root   738 Dec 11  2012 hello.cs
  -rwxrwxrwx 1 root root  2179 Dec 11  2012 hello.pl
  -rwxrwxrwx 1 root root  3395 Dec 11  2012 hello.php
  -rwxrwxrwx 1 root root  2260 Dec 11  2012 hello.js
  -rwxrwxrwx 1 root root  2347 Dec 11  2012 hello.lua
  -rwxrwxrwx 1 root root  2084 Dec 11  2012 hello.py
  -rwxrwxrwx 1 root root  2343 Dec 11  2012 hello.rb
  -rwxrwxrwx 1 root root   810 Dec 11  2012 hello.java
  -rwxrwxrwx 1 root root  1253 Dec 14  2012 mysql.c_
  -rwxrwxrwx 1 root root  3288 Dec 20  2012 memcached.c_
  -rwxrwxrwx 1 root root  5460 Dec 21  2012 json_bench.c
  -rwxrwxrwx 1 root root  1381 Dec 21  2012 hello.cpp
  -rwxrwxrwx 1 root root  1778 Dec 23  2012 throttle.c
  -rwxrwxrwx 1 root root  1747 Dec 25  2012 hello.d_
  -rwxrwxrwx 1 root root   873 Dec 25  2012 hello.scala_
  -rwxrwxrwx 1 root root  3414 Dec 25  2012 rnd.c
  -rwxrwxrwx 1 root root  2457 Dec 25  2012 auth_oauth.c_
  -rwxrwxrwx 1 root root   830 Dec 25  2012 hello.c
  -rwxrwxrwx 1 root root  1043 Dec 25  2012 argv.cs
  -rwxrwxrwx 1 root root  1920 Jan  5  2013 cookies.c
  -rwxrwxrwx 1 root root  4062 Jan 25  2013 setheaders.c
  -rwxrwxrwx 1 root root  2389 Jan 25  2013 noheaders.c
  -rwxrwxrwx 1 root root  1231 Jan 28  2013 redirect2.c
  -rwxrwxrwx 1 root root  2832 Feb 13  2013 stream1.c
  -rwxrwxrwx 1 root root  3130 Feb 13  2013 extern.c
  -rwxrwxrwx 1 root root  3233 Feb 13  2013 stream2.c
  -rwxrwxrwx 1 root root  7909 Feb 18  2013 imgsz.c_
  -rwxrwxrwx 1 root root  1393 Feb 19  2013 cookie.c
  -rwxrwxrwx 1 root root 12674 Feb 19  2013 entity.c
  -rwxrwxrwx 1 root root  2062 Feb 19  2013 entity_size.c
  -rwxrwxrwx 1 root root  9523 Feb 26  2013 loan.cs
  -rwxrwxrwx 1 root root  7164 Feb 26  2013 loan.php
  -rwxrwxrwx 1 root root 12982 Feb 26  2013 loan.c
  -rwxrwxrwx 1 root root  7832 Feb 26  2013 auth_basic.c
  -rwxrwxrwx 1 root root  8788 Mar  2  2013 stream3.c

  /opt/gwan64/18.104.22.168_80/#188.8.131.52/csp/folder:
  total 12
  -rwxrwxrwx 1 root root 1453 Dec 21  2012 hellox.c
  -rwxrwxrwx 1 root root 1033 Dec 21  2012 hello.c
  -rwxrwxrwx 1 root root 1295 Dec 21  2012 argv.c

  /opt/gwan64/220.127.116.11_80/#18.104.22.168/www:
  total 36
  -rwxrwxrwx 1 root root  100 Nov 24  2009 100.html
  -rwxrwxrwx 1 root root 1136 Mar  8  2012 csp_contact.html
  -rwxrwxrwx 1 root root 5036 Mar 24  2012 csp_comet.html
  -rwxrwxrwx 1 root root 1663 Oct 17  2012 csp_entity.html
  -rwxrwxrwx 1 root root 3834 Feb 11  2013 csp_loan.html
  drwxrwxrwx 2 root root 4096 Mar  8  2013 imgs
  -rwxrwxrwx 1 root root 7497 Mar 14  2013 index.html

  /opt/gwan64/220.127.116.11_80/#220.127.116.11/www/imgs:
  total 128
  -rwxrwxrwx 1 root root   102 Apr  7  2011 gwan16.gif
  -rwxrwxrwx 1 root root   202 Jun 29  2011 gwan_pw.gif
  -rwxrwxrwx 1 root root   284 Jul  4  2011 rss.png
  -rwxrwxrwx 1 root root   206 Jul  4  2011 gwan_rulez.gif
  -rwxrwxrwx 1 root root   470 Aug 13  2011 errors.css
  -rwxrwxrwx 1 root root   748 Mar 21  2012 ajax.js
  -rwxrwxrwx 1 root root  2807 Mar 21  2012 comet.js
  -rwxrwxrwx 1 root root 81114 Oct  1  2012 OOW_new_demo.jpg
  -rwxrwxrwx 1 root root  1308 Jan 13  2013 dl.css
  -rwxrwxrwx 1 root root 10561 Jan 17  2013 style.css
  -rwxrwxrwx 1 root root  1913 Feb 18  2013 watermark.png

  /opt/gwan64/logs:
  total 20
  -rwxrwxrwx 1 root root 14344 Jan  9 18:10 gwan_2016-01-09.log
  -rw-rw-rw- 1 root root  3674 Jan 10 14:32 gwan.log
</code>
Comment: So what do you get when you execute `ls -ltrR /opt/gwan64`? By the way, since you are executing this as root you certainly do not need the chmod 777.
Comment: Hi Law29, I added the requested data :-)
Comment: According to http://gwan.com/faq#listener the `_logs` directory should be named `logs`, but if that's not it I don't know. You might want to contact their support.
Comment: After the renaming of _logs to logs, the problem remains halas...
Comment: Any G-WAN user please ?
Comment: You can try to summon @Gil http://serverfault.com/users/107660/gil but he is "Last seen Jul 31 '15 at 9:48"
Answer: I was able to download today, on the official web site of G-WAN, the last version 7.12.2 and all is now working perfectly !


Hibernate doesn´t work as expected

Question: I am trying to update MySQL table with hibernate. It looks like that it does work, result from hibernate is 1, but table doesn´t change. My code for update :
Session session = GeneralSession.getSession();
session.beginTransaction();

//some code - initialization and logics
//loop
Query updateDuplicity = session .createSQLQuery("UPDATE `t_inzerat` set `actual` = 'D'
WHERE `id` = "+ idSimi);
int resultUpdate = updateDuplicity.executeUpdate();

session.flush();
//end of loop

session.getTransaction().commit();

In console hibernate writes this as:
Hibernate: UPDATE `t_inzerat` set `actual` = 'D' WHERE `id` = 5611
Affected rows : 1

Please what is wrong? Thank you
Comment: any specific reason for using statements instead of prepared statements?
Answer: Have a look hereexample. Do the commit in the tx returned by beginTransaction method
Comment: this statement is ok???
Query updateDuplicity = session    .createSQLQuery("UPDATE `t_inzerat` set `actual` = 'D' WHERE `id` = "
+ idSimi);
Comment: You can try to run it directly in the sql console. If works there is ok. I would not use "`"

Hibernate doesn´t work as expected


"float" text (with border) right AND stay in it's parent div

Question: thanks for any help in advance.
I guess it's something simple but i don't get it.
The button should be at the bottom right and the border should not going bonkers.
I said float in the Headline but thats just to clarify things. I'm pretty sure thats not how i should do this.
Heres my HTML:

        TeamSpeak³

        some text here
 some more text
 some more text

        Join

And the CSS:
.boxtest1 {
  height: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
  width: 38%;
  border: 4px solid #ff5857;
  border-radius: 0px 40px 0px 40px;
  background: rgba(255,88,87,0.2);
}
#sbts {
  text-align: center;
  font-size: 2em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsinfo {
  text-align: left;
  font-size: 1em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsbutton {
  direction: rtl;
  font-size: 1.5em;
  margin: 2px;
  padding: 2px;
  border: 2px solid #ff5857;
  border-radius: 0px 20px 0px 20px;
}
#sbtsbutton a {
  text-decoration: none;
  color: #BDBDBD;
}
#sbtsbutton:hover {
  background: #228822;
}

http://codepen.io/6P14y3r/pen/ZaEKag

Sorry if my english is bad ^.^
Comment: I'm not sure what do you mean, but if you're asking about problem with bottom right corner when button slightly overlaps container - you simply need to make `border-radius` values for container and button to match. So `#sbtsbutton { border-radius: 0px 20px 0px 40px; }` should fix this issue.
Comment: thats not my problem - the border of the button takes the whole width of the parent container but should only be as big as the "Join" text
Answer: if you add overflow: hidden; to the parent's CSS and clear: both;
float: right to the child's CSS it should solve your problem :)
Answer: If I understand correctly you should add display: table in .boxtest1 and float: right: right in #sbtsbutton
.boxtest1 {
  height: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
  width: 38%;
  border: 4px solid #ff5857;
  border-radius: 0px 40px 0px 40px;
  background: rgba(255,88,87,0.2);
  display: table;
}
#sbtsbutton {
  direction: rtl;
  font-size: 1.5em;
  margin: 2px;
  padding: 2px;
  border: 2px solid #ff5857;
  border-radius: 0px 20px 0px 20px;
  float: right;
}

Answer: If i am sure you are trying to get border same as the join text,
please see this snippet,

.boxtest1 {
  height: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
  width: 38%;
  border: 2px solid #ff5857;
  border-radius: 0px 40px 0px 40px;
  background: rgba(255,88,87,0.2);
}
#sbts {
  text-align: center;
  font-size: 2em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsinfo {
  text-align: left;
  font-size: 1em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsbutton {
  direction: rtl;
  font-size: 1.5em;
  margin: 2px;
  padding: 2px;
  border: 2px solid #ff5857;
  border-radius: 0px 20px 0px 20px;
}
#sbtsbutton a {
  text-decoration: none;
  color: #BDBDBD;
}
#sbtsbutton:hover {
  background: #228822;
}

        TeamSpeak³

        some text here
 some more text
 some more text

        Join

Comment: did you even change something? :)
Comment: oh yeah,
i misunderstood this comment  :: thats not my problem - the border of the button takes the whole width of the parent container but should only be as big as the "Join" text,

and  changed border of boxtest1 class,
why you are smiling brother?
Comment: oh yeah,no one forbidden to be happy but you are laughing on me.
Comment: would never do that :)
Answer: Replace your css with this css:
.boxtest1 {
  height: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
  width: 38%;
  border: 4px solid #ff5857;
  border-radius: 0px 40px 0px 40px;
  background: rgba(255,88,87,0.2);
}
#sbts {
  text-align: center;
  font-size: 2em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsinfo {
  text-align: left;
  font-size: 1em;
  color: #BDBDBD;
  border-bottom: 2px dotted #ff5857;
}
#sbtsbutton {
  direction: rtl;
  padding:20px 15px;
}
#sbtsbutton a {
  text-decoration: none;
  color: #BDBDBD;
  font-size: 1.5em;
  margin: 2px;
  padding: 2px;
  border: 2px solid #ff5857;
  border-radius: 0px 20px 0px 20px;

}
#sbtsbutton a:hover {
  background: #228822;
}

Answer: if I find you well,do this to get a better design

        TeamSpeak³

        some text here
 some more text
 some more text

        Join

   .boxtest1 {
  height: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: 32px;
  width: 38%;
  border: 4px solid #ff5857;
  border-radius: 0px 40px 0px 40px;
  background: rgba(255,88,87,0.2);
/*my changes*/
  float:left;
  margin-left: 31%;
}
#sbtsbutton {
  direction: rtl;

  font-size: 1.5em;
  margin: 2px;
  padding: 2px;
  border: 2px solid #ff5857;
  border-radius: 0px 20px 0px 20px;
/*my changes*/
  float:right;
  padding:5px 20px;
}


Metatag aleatoria

Question: Usamos as metatags de OpenGraph pra detalhar um pouco mais o nosso site no Facebook por exemplo.

<meta property="og:locale" content="pt_BR">

<meta property="og:url" content="site.com/blablabla">

<meta property="og:title" content="Título">
<meta property="og:site_name" content="Nome">

<meta property="og:description" content="Descrição">

<meta property="og:image" content="site.com/img.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="800">
<meta property="og:image:height" content="600">

<meta property="og:type" content="website">

Como eu faço pra deixar os valores entre as aspas (por ex: "Nome", "Descrição") com valores diferentes a cada refresh e que o "Titulo" seja parte da url digitada, pro exemplo: site.com/nomeusuario, e assim o og:site:title seja "nomeusuario", é possível?
Comment: Já tentou usar `` ?
Answer: Se você quiser buscar o url do site, recomendo usar $_SERVER['PHP_SELF'], irá buscar o nome do site e irá apresentá-lo.
Pode chamá-lo assim, <meta property="og:title" content="<?=$_SERVER['PHP_SELF']; ?>">.
Para uma melhor apresentação, recomendo substituir quaisquer _ ou - com espaços vazios para melhor apresentação usando o str_replace(), assim ficaria o código:
$site_url = $_SERVER['PHP_SELF'];
$site = str_replace("_"," ",$site_url);

E no OpenGraph ponha:
<meta property="og:title" content="<?=$site; ?>">

Metatag aleatoria


Dificuldade com Select

Question: Quero fazer uma consulta de 1 tabela que possui os registros:
Predio |  Local | Produto | FIFO

P01    |  WH01  |  Maçã   | 21/02/17

P01    |  WH01  |  Maçã   | 22/02/17

P01    |  WH01  |  Maçã   | 23/02/17

P01    |  WH01  |  Maçã   | 28/02/17

P01    |  WH01  |  Maçã   | 01/03/17

P01    |  WH01  |  Pera   | 10/10/17

P01    |  WH01  |  Pera   | 11/10/17

P01    |  WH01  |  Pera   | 12/10/17

P01    |  WH01  |  Pera   | 14/10/17

P01    |  WH01  |  Pera   | 15/10/17

P01    |  WH01  |  Pera   | 28/10/17

P01    |  WH01  |  Pera   | 29/10/17

P01    |  WH01  |  Manga  | 05/11/17

P01    |  WH01  |  Manga  | 08/11/17

P01    |  WH01  |  Abacaxi| 01/12/17

P01    |  WH01  |  Abacaxi| 10/12/17

Onde por prédio e local, a quantidade maxima de produtos são 3, o que eu queria era descartar a coluna FIFO para não trazer mais que 1 resultado dos produtos.
Tentei a Query:
SELECT DISTINCT

Predio,
Local,
Produto,
count(Produto) Qnt_de_PNs

FROM

Controle_Prod_P_Local_E_Predio

WHERE

  Local BETWEEN ('LOCA"')
            AND ('LOCA_FINAL')

  AND Predio BETWEEN ('Predio')
                 AND ('Predio_FINAL')
  AND Qnt_de_PNs > 3

GROUP BY Predio, Local, Produto

Resultado:
Predio |  Local | Produto | Qnt_de_PNs

P01    |  WH01  |  Maçã   | 5

P01    |  WH01  |  Pera   | 7

Porém sabemos que existem 4 produtos (Maçã, Pera, Manga e Abacaxi), o que eu preciso e que o campo Qnt_de_PNs me traga o resultado de 4.
Isso ocorre, pois o resultado do count se baseia nos registros com FIFO.
Conseguem me ajudar?
Comment: Não consegui entender a necessidade
Comment: `Qnt_de_PNs` deve mostrar 4 em todas as linhas?
Comment: Os meus locais não podem ter mais que 3 produtos diferentes. Precisava buscar apenas os locais com mais de 3 produtos.
Answer: Tente colocar o distinct na função:
SELECT

Predio,
Local,
Produto,
count(DISTINCT Produto) Qnt_de_PNs

FROM

Controle_Prod_P_Local_E_Predio

WHERE

  Local BETWEEN ('LOCA"')
            AND ('LOCA_FINAL')

  AND Predio BETWEEN ('Predio')
                 AND ('Predio_FINAL')
  AND Qnt_de_PNs > 3

GROUP BY Predio, Local, Produto

Comment: Rovann, Obrigado! Com o distinct no count todas as linhas ficaram com 1 no campo Qnt_de_PNs. Depois fiz um SUM utilizando uma sub query e consegui o resultado que precisava.
Comment: eu nem verifiquei o resto da query... considerei que a sintaxe que ele postou estava correta. Mas posso verificar depois isso
Comment: @JAN tenta colocar isso no SQLFiddle, acho que tem como melhorar.
Answer: Você precisa retirar do seu where a condição Qnt_de_PNs > 3. Desse modo:
SELECT DISTINCT

Predio,
Local,
Produto,
count(Produto) Qnt_de_PNs

FROM

Controle_Prod_P_Local_E_Predio

WHERE

  Local BETWEEN ('LOCA"')
        AND ('LOCA_FINAL')

  AND Predio BETWEEN ('Predio')
             AND ('Predio_FINAL')

GROUP BY Predio, Local, Produto

Comment: Agradeço a resposta, porém não é bem isso. Gostaria de saber quais os local com mais de 3 produtos, pois por padrão só deixaremos 3 por cada local. E efetuarei uma pesquisa em range, por isso queria filtrar o máximo possível

Dificuldade com Select


Best Practise to expose service in kubernetes using Calico

Question: Having set up a kubernetes cluster with calico for the one-ip-per-pod networking, I'm wondering what the best practise is to expose services to the outside world.
IMHO I got two options here, BGP'ing the internal pod IP's (172...) to an edge router/firewall (vyos in my case) and do an SNAT on the firewall / router. But then I'd need one public IP per pod to expose.
Pro: less public IP's need to be used
Con: Pod changes need updated firwall rules?!
Or 2nd: Taking the provided public network and hand it over to calico as an IP pool to be used for the pods.
Con: lots of public IP's wasted for internal services which won't get exposed to the internet
Hope someone could enlighten me or point me in the right direction.
Thanks!
Answer: Calico doesn't provide any special way to expose services in Kubernetes.  You should use standard Kubernetes services, node ports and the like to expose your services.  In the future, there's a possibility that Calico will offer some of the features that kube-proxy currently does for Kubernetes (such as exposing service IPs) but right now, Calico fits in at the low-level networking API layer only.  Calico's real strength in the Kubernetes integration is the ability to define network security policy using the new Kubernetes NetworkPolicy API.
Source: I'm one of Calico's core developers.
Comment: Hi Fasaxc, first, thanks for your answer and for your work on calico, I think it's a great project.
My question originated from what I saw on a video from the CoreOS Fest '15 where  Spike Curtis said that you could connect Calico directly to your Infrastructure to advertise routes outside your datacenter to let people connect straight in. This made me wonder how it would be done correctly. Check out the [Video at 13:05](https://www.youtube.com/watch?v=44wOK9ObAzk&feature=youtu.be&t=13m05s)
Comment: If you were running OpenStack or raw Docker, say, then you'd only have one set of IPs, which would be exposed.  The difference is Kubernetes has its service infrastructure, which sits in front of the pod IPs.  We haven't "taken over" that feature from Kubernetes and "Calico-ised" it (yet), but we may do in the future.  Right now, if you want the k8s experience, with service IPs etc then you need to run kube-proxy in front of Calico.
Comment: @Fasaxc        why is it that i cant use ipBlock when using calico and kubernetes 1.7?
Comment: I found this article [here](https://www.projectcalico.org/enable-ipv6-on-kubernetes-with-project-calico/), it seems to suggest a setup using calico to expose kubernetes resources (perhaps not services) with calico. Would be great to have ipv6 support.
Answer: Calico is not responsible for the k8s service IP management or for translating service ip to container (workload endpoint) It allocates IP addressses to the newly created pods and does necessary system config changes to implement the calico policies


Set a background alarm for the near future Android

Question: Please help me solve the problem with creating an alarm clock in Android.
My application needs to notify the user of an event at the time specified by him. These events happen in 5-10 minutes.
The first thing I tried to do was use the AlarmManager and its setExactAndAllowWhileIdle and set Alarm Clock methods. This works while the device is active, but the alarms don't go off when the device is in sleep mode. At the same time, as soon as I touch the device, the alarm clock worked. It doesn't suit me.
Then I tried using the Foreground Service. But the service also stops when the phone goes to sleep mode.
I also tried using wakelock, but the service is suspended anyway.
Is there any way to create an accurate alarm clock that will go off 5-10 minutes after it is set when the phone is in sleep mode?
I have been trying to solve this problem for a week now and there is no result. Please help me figure it out.
Answer: i have faced the same problem before setExactAndAllowWhileIdle() is designed to fire while the phone is in sleep mode but it will not wake it up and it hass some restrictions so it's not really exact try using setAlarmClock() this one is designed to to make the system exits sleep mode before the alarm fires code example:
<code>val intent =
    Intent(context, AlarmReceiver::class.java).apply {

        addFlags(Intent.FLAG_FROM_BACKGROUND)
    }

alarmManager.setAlarmClock(
    AlarmManager.AlarmClockInfo(
        LocalDateTime
            .now()
            .atZone(ZoneId.systemDefault())
            .toEpochSecond() * 1000 + alarmItem.alarmIn * 1000,
        null,
    ),
    PendingIntent.getBroadcast(
        context,
        alarmItem.id.hashCode(),
        intent,
        PendingIntent.FLAG_UPDATE_CURRENT or
         PendingIntent.FLAG_IMMUTABLE,
    ),
</code>
This article explain this topic well : https://medium.com/@igordias/android-scheduling-alarms-with-precise-delivery-time-using-alarmmanager-75c409f3bde0

another thing you need to consider when using alarm manager when the device is rebooted the system will cancel all alarms to solve that you need to save those alarms using sqldelight for example and adding a broadcast receiver to schcedule them again when the device is rebooted

also using foreground service like you did is needed and do not forget to use broadcast receiver to receive those alarms


How to solve limit of $(n-1)\left[1-\left(1-\left(\frac{\lambda}{n}\right)^2\right)^{n-1}\right]$?

Question: I'm trying to find the solution to the following limit:
$$
\lim_{n\rightarrow\infty}(n-1)\left[1-\left(1-\left(\frac{\lambda}{n}\right)^2\right)^{n-1}\right]\ \mathrm{.}
$$
I've tried decomposing the limit and writing it as
$$
\lim_{n\rightarrow\infty}(n-1)\left[1-\left(1-\frac{\lambda}{n}\right)^{n}\left(1+\frac{\lambda}{n}\right)^n\left(1-\left(\frac{\lambda}{n}\right)^2\right)^{-1}\right]\ \mathrm{,}
$$
so I can use that
$$
\lim_{n\rightarrow\infty}\left(1\pm\frac{\lambda}{n}\right)^{n}=e^{\pm\lambda}\mathrm{,}
$$
but the problem seems to be that I cannot split the products or the sums within the limit into separate limits as $\lim_{n\rightarrow\infty}(n-1)$ does not converge. The answer should be $\lambda^2$ (this is also what Wolfram gives me), but I don't see a way to get to that answer myself. I'd rather not resort to the Laurent series, as this is also a nightmare to compute. Can anyone help?
Comment: You can use $(1-a)^b=e^{b\ln(1-a)}$. Also, for $a<1$, $\ln(1-a)=-a-\frac{a^2}{2}-\frac{a^3}{3} - ... $ and $e^a=1+a+\frac{a^2}{2!}+\frac{a^3}{3!}+.... $. Then you group the terms with the same power of $a=\frac{1}{n}$, and lead $\frac{1}{n}\to0$
Answer: We have that by $\log (1+x)=x+O(x^2)$ and $e^x=1+x+O(x^2)$
$$\left(1-\left(\frac{\lambda}{n}\right)^2\right)^{n-1}=e^{(n-1)\log\left(1-\left(\frac{\lambda}{n}\right)^2\right)}=e^{-\frac{(n-1)\lambda^2}{n^2}+O\left(\frac1{n^3}\right)}=1-\frac{(n-1)\lambda^2}{n^2}+O\left(\frac1{n^3}\right)$$
therefore
$$(n-1)\left[1-\left(1-\left(\frac{\lambda}{n}\right)^2\right)^{n-1}\right]=\frac{(n-1)^2\lambda^2}{n^2}+O\left(\frac1{n^2}\right) \to \lambda^2$$
Comment: (+1) Nice answer. It's much shorter than mine.
Comment: @JoséCarlosSantos Thanks! Your also is very fine!
Answer: Note that\begin{multline}\lim_{n\to\infty}(n-1)\left(1-\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}\right)\\=\lim_{n\to\infty}n\left(1-\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}\right)-\lim_{n\to\infty}\left(1-\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}\right)\end{multline}(as long as both limits exist), but$$\lim_{n\to\infty}\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}=\lim_{n\to\infty}\left(1-\left(\frac\lambda n\right)^2\right)^n\left(1-\left(\frac\lambda n\right)^2\right)^{-1}=1,$$and therefore$$\lim_{n\to\infty}\left(1-\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}\right)=0$$So, all you need is to compute$$\lim_{n\to\infty}n\left(1-\left(1-\left(\frac\lambda n\right)^2\right)^{n-1}\right),$$which is equal to$$\lim_{h\to0}\frac{1-\left(1-\lambda^2h^2\right)^{1/h}}h\tag1$$(again, if it exists). Now, you can use the fact that$$\left(1-\lambda^2h^2\right)^{1/h}=e^{\log(1-\lambda^2h^2)/h}$$and that, near $0$, you have$$\frac{\log(1-\lambda^2h^2)}h=-\lambda^2h-\frac{\lambda ^4 h^3}{2}-\frac{\lambda^6 h^5}{3}+\cdots$$and therefore$$e^{\log(1-\lambda^2h^2)/h}=1-\lambda ^2 h+\frac{\lambda ^4h^2}{2}+\left(-\frac{\lambda^6}6-\frac{\lambda^4}2\right) h^3+\cdots$$It follows from this that $(1)$ is equal to $\lambda^2$, and then so is the limit of your sequence.


Select all entries where somewhere in their string is `h`, after that, there is a `e`, `l` and `o`

Question: Given are entries in a column wort in a table woerter like this
henlo
oenlh
olneh

I am looking for a sqlite command that lists all entries of word containing h e l o(for the sake of example, in fact those letters are always different) - in that order. So in this example the result should be

henlo

as there is
henlo
In other words: Select all entries where somewhere in their string is h, after that, there is a e, l and o. It does not need to be right after it, but somewhere after it. For instance:

ssssshssssssessssssslsssossssso

would be in the results,

ssosssssossssshssssssesssssssls

would not.
My approach so far:

SELECT * FROM woerter WHERE wort LIKE 'h%' AND wort LIKE '%e%'  AND
  wort LIKE '%l%'  AND wort LIKE '%o'

which is flawed because it does not properly integrate the order for e and l and it requires h and o to be at the beginning and end.
Comment: Does the "elo" need to be in that order - ie would "xxxhxxxloexx" match?
Answer: You can use wildcard's in the middle of strings
SELECT * FROM woerter WHERE wort LIKE '%h%e%l%o%'

This searches for any word that has N characters, followed by h, followed by N characters, followed by e, etc.
The % wildcard matches any number of characters and by putting all this in a single condition you ensure that the characters are in the correct order.
To quote from the documentation:

A percent symbol ("%") in the LIKE pattern matches any sequence of zero or more characters in the string

Your conditions don't quite allow for the character to appear in any place in the string. As the percent symbol is a wildcard like 'h%' would only be true if the h was at the beginning of the string. Similarly with like '%o' the o must be at the end of the string.
This means that you're selecting any word that begins with h, has an e and a l somewhere in the string and ends in o.


How to show token value in Webform confirmation

Question: In Webform > Form settings > Submission settings > Confirmation message, how can I show a webform token as part of the confirmation message? Something like:

Hi <code>%value[name]</code>, thanks very much for joining our event!
Answer: Use Webform tokens module

Webform Tokens provides tokens for user form submissions for forms
  created with the module Webform 3.

Or upgrade to Webform4 which has this feature inbuilt.


Spivak Chapter 11 Appendix Problem 10b

Question: I have solved part A, but I am failing to make any progress at all for part b. Can someone at least lead me in a direction? This problem is very difficult to visualize intuitively (for me), and I'm not sure how I would even go about solving it.

(a) For any function $f$, the right-hand derivative $\lim_{h\to0+}[f(a+h)-f(a)]/h$, is denoted by $f'_+(a)$, and the left-hand derivative is denoted by $f'_-(a)$. The proof of Theorem 1 actually shows that $f'_+$ and $f'_-$ always exist if $f$ is convex. Check this assertion, and also show that $f'_+$ and $f'_-$ are increasing, and that $f'_-(a)\leq f'_+(a)$.
(b) Show that if $f$ is convex, then $f'_+(a)=f'_-(a)$ if and only if $f'_+$ is continuous at $a$. (Thus $f$ is differentiable precisely when $f'_+$ is continuous.) Hint: $[f(b)-f(a)](b-a)$ is close to $f'_(a)$ for $b<a$ close to $a$, and $f'_+(b)$ is less than this quotient.

Here's my progress to part (a) here, since amWhy requested it:
Consider $f_+'$. Note that because $f$ is convex, considering $h>0$, we have that $\frac{f(a+h)-f(a)}{h}$ is decreasing. Not only so, it is bounded by $\frac{f(a-h)-f(a)}{h}$ for any positive $h$. A decreasing sequence with a lower bound, therefore, has a limit. The proof for f- is similar.
Next, to show that $f_+'$ is increasing, we'll consider 2 points $a, b$. Note that $f_+'(a)<\frac{f(b)-f(a)}{b-a}$ (use the limit definition if you'd like), and that $f_-'(b)>\frac{f(b)-f(a)}{b-a}$. Therefore, $f_+'(a)<f_-'(b)$.
Now, we'll show that $f_-'(a) \le f_+'(a)$. To do this, note that any $\frac{f(a+h)-f(a)}{h}$ is larger than $\frac{f(a-h)-f(a)}{h}$.
Finally, $f_-'(a) \le f_+'(a) < f_-'(b) \le f_+'(b)$, which shows that $f_+$ and $f_-$ are increasing.
Comment: I'm not studying convex analysis, but rather calculus...
Comment: I think Spivak would prefer readers asking rather than spending time to read another book in case of doubt.
Comment: This is standard stuff, check out books on Convex Analysis: Rockafellar, Boyd-Vandenberghe and many others.
Comment: Fair enough. I suggest you google Boyd-Vandenberghe's convex optimization book, which is available for free. It should be in there.
Answer: Using Spivak's suggestion:
You should have proven in part (a) that if $b<a<c$, then
$$\tag1
\frac{f(b)-f(a)}{b-a}\leq f'_-(a)\leq f'_+(a)\leq \frac{f(c)-f(a)}{c-a}
$$
Suppose that $f'_-(a)=f'_+(a)$. Fix $\varepsilon>0$. Then there exists $\delta>0$ such that if $0\leq a-b<\delta$, then
$$\tag2
0\leq f'_-(a)-\frac{f(b)-f(a)}{b-a}<\varepsilon.
$$
Similarly, if $0<b-a<\delta$,
$$\tag3
0\leq \frac{f(b)-f(a)}{b-a}-f'_+(a)<\varepsilon.
$$
Thus, if $0<b-a<\delta$, we get from $(3)$ that
$$
0\leq f'_+(b)-f'_+(a)\leq\frac{f(b)-f(a)}{b-a}-f'_+(a)<\varepsilon.
$$
This shows that $f'_+$ is right continuous, which doesn't require the hypothesis.
Now if
if $0<a-b<\delta$, using $(2)$ we get
$$
0\leq f'_+(a)-f'_+(b)=f'_-(a)-f'_+(b)<\varepsilon+\frac{f(b)-f(a)}{b-a}-f'_+(b)\leq\varepsilon.
$$
So $f'_+$ is also right-continuous at $a$, and so it is continuous at $a$.
Conversely, if $f'_+$ is left-continuous at $a$ (recall that it is always right-continuous), given $\varepsilon>0$ there exists $\delta>0$ such that for $0<a-b<\delta$ we have
$$\tag4
0\leq f'_+(a)-f'_+(b)<\varepsilon.
$$
Then
$$
0\leq f'_+(a)-f'_-(a)<\varepsilon+f'_+(b)-f'_-(a)\leq\varepsilon+\frac{f(b)-f(a)}{b-a}-f'_-(a)\leq\varepsilon.
$$
As $\varepsilon$ was arbitrary, $f'_+(a)=f'_-(a)$.

Note: for the second to last inequality we have, since $b<a$,
$$
f'_+(b)\leq \frac{f(a)-f(b)}{a-b}=\frac{f(b)-f(a)}{b-a}.
$$
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/71324/discussion-on-answer-by-martin-argerami-spivak-chapter-11-appendix-problem-10b).

Spivak Chapter 11 Appendix Problem 10b


Ubuntu16 cannot install pyheif

Question: I'm trying to install pyheif to use heic files on Linux server.
pyheif: https://pypi.org/project/pyheif/
Linux library command:
sudo apt-get install python3 python3-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev python3-pip

sudo apt-get install libpcap-dev libpq-dev

apt install libffi6 libheif-dev libde265-dev  <-- I cannot find libffi. only libffi6 is available.

Now then I try to install pyheif
pip3 install pyheif

TRACEBACK:
...long lines ...
    build/temp.linux-x86_64-3.6/_libheif_cffi.c: In function '_cffi_d_heif_context_read_from_memory_without_copy':
    build/temp.linux-x86_64-3.6/_libheif_cffi.c:2375:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pfesa6xd/pyheif/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-me_rlsh8-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-pfesa6xd/pyheif/

How can I install pyheif?
How can I solve that tracebacks.
Comment: I'm voting to close this question because it would be better on askubuntu
Comment: There should be a more detailed error message above the lines you posted.
Answer: https://github.com/carsales/pyheif/issues/44
We can install from wheel anyway. The problem why wheel was not used was matching the tags (manylinux), in particular pip was missing the cp36-cp36m-manylinux2014_x86_64 (had only cp36-cp36m-manylinux2010_x86_64). This was due to an older version of pip (19.2), rather than 19.3.
pip install -U pip
pip install pyheif

Ubuntu16 cannot install pyheif


O Pytesseract não reconhece apenas uma letra

Question: Eu preciso reconhecer apenas uma letra através da biblioteca Pytesseract em python mas o OCR não é capaz de reconhecer quando é só uma letra.
Neste caso, estou tentando reconhecer a letra H, mas nada aparece !
O que posso fazer para que ele reconheça?
from PIL import Image
from pytesseract import *
import cv2
img = cv2.imread('H.png',0)
edges = cv2.Canny(img,100,200)
img_new = Image.fromarray(edges)
text = pytesseract.image_to_string(img_new, lang='eng')
print (text)

Answer: text = pytesseract.image_to_string(img_new, lang='eng', config='--psm 10')

Créditos para a resposta :
https://stackoverflow.com/questions/54119597/pytesseract-does-not-recognize-when-its-just-a-letter