Loader load only selected row + next row

Question: In activity A I am loading a list with all the values from my table and have set a setOnItemClickListener to start activity B and send an uri with the selected item's id[1] via send data
[1]
Uri currentTestUri = ContentUris.withAppendedId(TestEntry.CONTENT_URI, id);
In activity B I have my onCreateLoader with the projection:
String[] projection = {
       TestEntry._ID,
       TestEntry.COLUMN_TEST_ONE,
       TestEntry.COLUMN_TEST_TWO}

...with the return statement
return new CursorLoader(this,
    mCurrentTestUri, //Got this from Activity A
    projection,
    null,
    null,
    null);

And my onLoadFinished looks something like this:
if (cursor.moveToFirst()) {
      int oneColumnIndex = cursor.getColumnIndex(TestEntry.COLUMN_TEST_ONE);
      int twoColumnIndex = cursor.getColumnIndex(TestEntry.COLUMN_TEST_TWO);

      String currentOne = cursor.getString(oneColumnIndex);
      String currentTwo = cursor.getString(twoColumnIndex);

      textViewOne.setText(currentOne);
      textViewTwo.setText(currentTwo);
}

So far so good, now I wish to show values from the next row (right beneath it) but with a different projection (I only need the _ID and COLUMN_TEST_ONE) and have onLoadFinished display COLUMN_TEST_ONE's value in textViewThree.

[values from both rows should be shown at the same time, not one or
  another]

I can get the ID of the next row from activity A with [2] and send it as a string via putExtra but that's about all I have so far.
[2]
String nextItemId = String.valueOf(listView.getItemIdAtPosition(position + 1));
if((position+1) < lListView.getCount()) {
    intent.putExtra("prevID", nextItemId);
}

..or I could create a valid URI path with the next row ID and send it as a string from Activity A and convert it to a URI in activity B if needed with:
ContentUris.withAppendedId(TestEntry.CONTENT_URI, nextItemId)

How should I change my activity B to load values from the next row
and the current one onCreate?
Comment: What does *"at the same time"* mean? Can you perephrase that part?
Comment: @azizbekian my bad, not exactly at the same time (as in literally) but when the activity starts (onCreate)
Answer: The problem is with your query:

    Uri currentTestUri = ContentUris.withAppendedId(TestEntry.CONTENT_URI, id);

Here you are specifying, that you want to query only rows, that have specific id. Any row, which has different id won't be returned in the Cursor.
Instead, query the table with appropriate selection arguments:

    // Load all rows that have id `firstId` or `secondId`
    return new CursorLoader(this,
        TestEntry.CONTENT_URI,
        projection,
        TestEntry._ID + "=? OR " + TestEntry._ID + "=?",
        new String[] {firstId, secondId},
        null);

Then you can get the value of secondId row following way:

    if (cursor.moveToFirst()) {
          ...

          textViewOne.setText(currentOne);
          textViewTwo.setText(currentTwo);

          if (cursor.moveToNext()) {
              int index = cursor.getColumnIndex(TestEntry.COLUMN_TEST_ONE);
              String next = cursor.getString(index);
              // Use `next` as needed, may be passed to next activity via extras
          }
    }

Comment: Glad that worked for you. Please do not reward bounty immediately, maybe somebody would come up with a better solution. As long as this will stay as a selected answer - the bounty will be rewarded automatically, no worries.
Comment: Worked like a charm! Thank you! Will be able to award the bounty only tomorrow but here, take a +1 till then!


Proof that covariance matrix is positive semi-definite (and not positive definite)

Question: The covariance matrix is given
$$
\Sigma_{\textbf{XX}} = \text{cov}[\textbf{X}, \textbf{X}] = E[(\textbf{X} - \mu_{\textbf{X}})(\textbf{X} - \mu_{\textbf{X}})^\top]
$$
We want to prove that $\Sigma_{\textbf{XX}}$ is positive semi-definite. For this, we can say that if $\Sigma_{\textbf{XX}} \in \mathbb{R}^{n\times n}$, $\forall \textbf{u} \in \mathbb{R}^n$
\begin{align}
\textbf{u}^\top \Sigma_{\textbf{XX}} \textbf{u} &=\textbf{u}^\top E[(\textbf{X} - \mu_{\textbf{X}})(\textbf{X} - \mu_{\textbf{X}})^\top]\textbf{u}\\
&= E[\textbf{u}^\top(\textbf{X} - \mu_{\textbf{X}})(\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u}]\\
&= E[((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^\top(\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u}]\quad \textbf{(1)}\\
&= E[((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^2]\ge 0 \quad \textbf{(2)}\\
\end{align}
Here are my 2 questions:

What is the linear algebra property allowing to go from $\textbf{(1)}$ to $\textbf{(2)}$?
What is the information that allows to state in the last equation that $E[((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^2]\ge 0$ and not $E[((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^2]> 0$ $\iff$ how can we state that $\Sigma_{\textbf{XX}}$ is positive semi-definite and not positive definite?

Edit
(thanks to John Hughes)
\begin{align}
\textbf{u}^\top \Sigma_{\textbf{XX}} \textbf{u}
&= E[\underbrace{((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^\top}_{\in \mathbb{R}}\underbrace{(\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u}}_{\in \mathbb{R}}]\\
&= E[((\textbf{X} - \mu_{\textbf{X}})^\top\textbf{u})^2]\ge 0 \\
\end{align}
Answer: Look at line 1 as having the form
$$
E[s^t s],
$$
where $s = (X - \mu_X)^t u$. Now $s^t s$ is, in general, the same as $s \cdot s$, so we can say that $s^t s = \| s \|^2$ (by definition of length!). In this case, it appears that $s$ is just a number, so $s^t s$ is simple $s^2$.
For your second question, look at the number $s$: it might always be zero, in which case $s^2$ would always be zero, so the expected value would always be $0$. When you have a non-negative random variable, the expected value is also non-negative, but not necessarily positive!
Comment: Many thanks @JohnHughes. Is the edit of my question reflects your point accurately regarding the first question? Regarding the question you mean $\text{X}$ could be the zero vector?
Comment: Sure .. the everywhere zero vector is a random variable, with mean $\mu_X$ being the zero vector, so you get a covariance of zero.
Comment: many thanks @JohnHughes


How to convert or equalize Query> to List

Question: I have BrandList in my Firebase like this;
How can I convert or equalize this Firebase List to List.
I tried this;
var brandsRef = _firestore.collection("vehicles1").where("Brands");
    List brandsList = brandsRef;

But I got this error "A value of type 'Query<Map<String, dynamic>>' can't be assigned to a variable of type 'List'."
Answer: First I would suggest to create a model of your class Brand in addition to the jsonSerialization classics:
class Brands {
  Brands({this.brandName});
  List<String> brandName;

  Map<String, dynamic> toMap() {
    return {
      'Brands': brandName,
    };
  }

  factory Brands.fromMap(Map<String, dynamic> map) {
    return Brands(
      brandName: List<String>.from(map['Brands']),
    );
  }

  String toJson() => json.encode(toMap());

  factory Brands.fromJson(String source) => Brands.fromMap(json.decode(source));
}

Then you need to add a few steps to the way you retreive elements:
   var response = _firestore.collection("vehicles1").where("Brands").get();

   final results =
        List<Map<String, dynamic>>.from(response.docs.map((e) => e.data()));
   Brands brands =
        results.map((e) => Brands.fromMap(e)).toList();

Answer: You need to use the document Id to get the query and then you can get the data which returns a Map.
From that Map, you can supply the key to retrieve the value. In this case, the key is "Brands".
var brandsQuery = await _firestore.collection("vehicles1").doc(document Id).get();
List brandList = brandsQuery.data()["Brands"];


Filter out "abnormally large" values from a list of data

Question: For example, the lists can be something like:
$$\{1.123213, 5.154543, 2.134121, 7.34534, 12.223432, 8.16571, 100.45645, 222.423\}$$
I want to remove $\{100.45645, 222.423\}$.
$$\{232.123213, 323.154543, 232.134121, 123.34534, 222.223432, 8545.16571,\\ 4335.45645, 1222.423\}$$
I want to remove $\{8545.16571, 4335.45645, 1222.423\}$.
The size is not fixed, and the range may vary.
Are there any ways to remove these "abnormally large" values from my lists?
Comment: A method advised by Tukey as a way of *flagging* "outliers" was to compare their values to 1.5*IQR above and below Q3 and Q1 respectively. With 25% of your sample consisting of "outliers", I don't think this method (or other methods) will be reliable. I generally don't advocate automating such processes since data can be weird and "outliers" can dramatically increase your power to detect trends. If you have data quality issues, *flagging* outliers can be good practice, but you may want to focus on feeding in higher quality data and reviewing it more closely.
Comment: An outlier is only an outlier with respect to some model (less formally, some expectation about what you should see). You have given examples of what you regard as outliers in two cases, but I see no clear way to generalize. In that second case is 800 an outlier? Is 500? If the 323 was 380, or 260 would that change your mind about 500?
Answer: I've added the outlier tag to your question, as that's how I understand your problem. Plenty of methods exist for outlier detection; I'll focus on this, since I assume deletion of detected outliers is trivial for you.
Tukey's fences are the simple, conventional statistics I've been taught to use for univariate outliers. I'd be eager to upvote any better answers here and welcome any further critique of this common method. Fence stats are, as I've said, very simple: the upper and lower bounds are defined by the inter-quartile range, multiplied by 1.5, which is then added to the 3rd quartile and subtracted from the 1st. E.g., in R:

Your first vector of data, X:

Upper fence:
1.5*(quantile(X,.75)-quantile(X,.25))+quantile(X,.75) $=79$

This identifies the two outliers you intended, 100.45645 and 222.423.

Lower fence: quantile(X,.25)-1.5*(quantile(X,.75)-quantile(X,.25)) $=-40$

Your second vector of data, Y:

Upper fence:
1.5*(quantile(Y,.75)-quantile(Y,.25))+quantile(Y,.75) $=4657$

This is more conservative than you were, only identifying 8545.16571 as an outlier.

Lower fence: quantile(X,.25)-1.5*(quantile(X,.75)-quantile(X,.25)) $=-2427$

The lower fences seem unneeded, but I've retained them for demonstration.
I see @AdamO has already raised a good point about your data and why this method may have failed. What justification do you have for calling two and three elements of your 2×8 observations abnormally large? If your data are sampled from larger populations of interest, do you really know what is normal for those populations' distributions? Consider this sample of a random normal distribution with $\mu=$ X's median and X's $SD$ after squaring (set.seed(1); sort(round(rnorm(8,median(X),sd(X))^2))):
$$\{496,1143,1745,2143,3262,3400,4373,17923\}$$
To reiterate, this is just a simulated sample of a squared normal distribution. There are no outliers in the square roots of these data (I checked), but Tukey's upper fence identifies 17923 as an outlier in the squared distribution. Here's the probability density function (pdf) of this distribution to give you a feel for what it looks like (plot(density(rnorm(100000,median(X),sd(X))^2),xlim=c(1500,45000))):

You're probably not going to want to trust Tukey's upper fence with a strongly, positively skewed (skewness $=2.8)$ distribution like this (somewhat similar to a $\chi^2$ distribution BTW, but probably more skewed and kurtotic than most). Tukey's upper fence identifies the top 7.5% of observations from this distribution as outliers, which is a bit much to shave off the top, and not really justified, considering that these observations are sampled from the same distribution as all the non-"outliers".
Outliers should generally be suspected of belonging to different distributions before disregarding them, and ideally you'd have more than just a univariate statistical basis for such a suspicion. For example, if you're sampling the local baseline of tectonic activity, it's probably safe to say you've sampled from a different distribution during moments when a herd of elephants is stampeding past your detector (which, let's say isn't designed to control for elephant stampedes). If these observations are univariate outliers (or bivariate outliers, considering elephant stampede? as a second binary variable you'd probably want to record, and hopefully wouldn't observe too often), I have no reason to tell you not to exclude them...but if you haven't seen any elephants lately, your high observations might not be proper outliers regardless of what Tukey's fences say. You should seek stronger justifications. If you only have these data and no idea what else might be affecting them, and if they're paired observations, you could consider methods of multivariate outlier detection, but I doubt this will be a big improvement.


determine which template file a contrib module is using?

Question: I'm using a contrib module. It doesn't seem to be using the right template file. I'm trying to triage whether the problem exists in my template or if it is just the hook template suggestion.
What is the cheapest way to debug which template file a particular contrib module is using?
FYI: i'm using the commerce export ftp module. It has it's own template inside the module but i'd like it to use the template file within my theme.
I would like an answer that would be a general debugging practice. Not one specific to this particular module: how do you dump the file path that the contrib module is using? Is the only way of doing so with devel_ui ? I'm looking for a programatic way of doing this.
Answer: I thing something like this could tell you what is going on :
<code>$reg = theme_get_registry();
dpm($reg['commerce_order_ftp_export']);
</code>


Do the 2022 FIFA World Cup ball sensors track the ball's location, and if so, how accurate is it?

Question: Follow-up of Why was Japan's second goal deemed to be valid?: do the 2022 FIFA World Cup ball sensors track the ball's location, and if so, how accurate is it?
Comment: A lot of this is answered [here](https://sports.stackexchange.com/a/28503/6126); I suspect you won't get a real answer to "how accurate is it" other than Adidas's marketing materials.
Answer: From https://sports.stackexchange.com/a/28503/1832:

From the manufacturer, Adidas:

Connected ball technology comes to Al Rihla for sport's biggest stage, providing the VAR team with precise ball data in real time to support fast and accurate offside calls

However, this tweet on the 2022 FIFA World Cup match between Japan and Spain shows the video that match officials used the goal line camera images to check whether the ball was still partially on the line. But no ball sensors are mentioned.


How to debug $.ajax not ending call

Question: I have a $.ajax call to upload an image to a php server, running on chrome, on an iphone.
This task, when tested on an iphone, have some none ending
upload task.  I started to call some alert on .done(), .fail(),
but nothing tells me what happen.  The $.ajax keeps running, as
showed by the iphone spinning wheel and I witness the file not being uploaded.
What variables, settings should I look for to get more information
on this none ending loop on the iphone dev?
Answer: You can debug the web content on iphone using safari or chrome:
safari: https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html
chrome: http://www.mosync.com/documentation/manualpages/debugging-javascript-ios-mosync-reload

How to debug $.ajax not ending call


Enable/open comments on all posts of a content type

Question: When I created a content type, I chose to keep the Comments hidden. Now I have many posts of that content-type and I want to open the comments, which I did by editing the content type, but it did not open comments of any posts of that content-type.
How do I open comments on all the posts of a content type at once?
How do I remove that little help box under comments text area?
Comment: Related from earlier: http://drupal.stackexchange.com/questions/4544/can-you-bulk-enable-comments
Answer: Or directly into the database with :
UPDATE `node`
SET comment = 2
WHERE comment = 1

and
UPDATE `node_revision`
SET comment = 2
WHERE comment = 1

Where : Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).
Answer: You'll have to edit your existing content and open the comments manually. If you have a lot of content you can probably do it directly in the database.
To remove the "help box" you can change the text format to "plain text" for the "comment body" field.
If you want to keep the HTML option you can use a hook_form_alter() function to remove the text.
Better Formats Module might also do the trick.
Comment: In the database, I changed comment=2 for all the records of the content-type, but it did not take effect, I still see comment closed of all those posts in Drupal.
Comment: interesting, maybe node_revision has to change as well?. When you open the comments in the UI it works, right? If you have a lot of nodes you could look into VBO (Views Bulk Operation)
Comment: Yes, I had to update node_revision table as well. In order to update 'comment' field of this table, it required an SQL statement using 'inner join' clause along with 'node' table since this table does not have 'type' field.
Answer: To enable comments you should use Views Bulk Operations. It allows you to define operations to be executed against any view result.
You have to write a custom Rules action, but it will definitely be worth your time.
Answer: In Drupal 7, you can run following code using Devel Module
$num_updated = db_update('node_revision')
  ->fields(array(
    'comment' => 2,
  ))
  ->condition('comment',1)
  ->execute();

echo "node revision table updated count: ".$num_updated ."," ;

$num_updated = db_update('node')
  ->fields(array(
    'comment' => 2,

  ))
  ->condition('comment',1)
  ->execute();

echo "node table updated count: ".$num_updated ;

Answer: For Drupal 7, you need to enable comments in both node and node_revision tables. Use this query
    UPDATE node as n LEFT JOIN node_revision as nr ON nr.nid=n.nid AND nr.vid=n.vid
SET n.comment = 2, nr.comment = 2 WHERE n.type = 'article'.
Answer: Adding node_type condition as following:
db_update("node")
->fields(array(
  'comment' => 2,
  ))
->condition("type", "node_type", "=")
->execute();

I can run the above with drush scr filename.php
Alternatively I could update with SQL query:
UPDATE node as n LEFT JOIN node_revision as nr ON nr.nid=n.nid AND nr.vid=n.vid
SET n.comment = 2, nr.comment = 2 WHERE n.type = 'notes';

Comment: Good solution i sorted out my issue with this suggestion Thanks
Answer: Very easy to update comment for drupal node
simply run two query

in node table
UPDATE 'node' SET 'comment' = '2' WHERE TYPE = ''

UPDATE node_revision  SET `comment` = '2' WHERE  nid in(select nid from node where type='rss_feed')

should be update in both table revision and node.
Answer: Just Run this Query in devel/php environment to enable comments for all existing content.

$num_updated = db_update('node')
->fields(array(
  'comment' => 2,
))
  ->condition('type', 'CONTENT_TYPE', '=')
  ->execute();

$subquery = db_select('node');
$subquery->addField('node', 'nid');
$subquery->condition('node.type', 'CONTENT_TYPE', '=');
$num_updated1 = db_update('node_revision')
  ->fields(array('comment' => '2',))
  ->condition ('node_revision.nid', $subquery, 'IN')
  ->execute();


Which file should my style be in

Question: I'm putting this question in the Drupal forum rather than a CSS forum as I don't know if I just have a CSS issue or if the issue is more Drupal, maybe how I'm using the .info file.
I'm using Drupal 7 with UberCart and the AT Commerce sub-theme of Adaptivethemes.
If I put my CSS in styles.base.css they take effect. However, it I put my CSS in a separate CSS then they do not.
I edited at_commerce.info so I have this
<code>// CSS
stylesheets[all][] = css/styles.custom.css
stylesheets[all][] = css/styles.base.css
stylesheets[all][] = css/styles.modules.css
stylesheets[all][] = css/styles.settings.css
stylesheets[all][] = color/colors.css
stylesheets[all][] = css/uc_product.css
</code>
I tried styles.custom.css as the first in the list as shown above and the last in the list and it make no difference. styles.custom.css is empty except for the 2 styles I'm trying to put there. When I put the 2 styles in styles.base.css I am putting them at the bottom of the file.
Comment: I failed to say clearly that the 'separate css file' is styles.custom.css. The styles don't work when I put them in this file.
Comment: Your css should work. Maybe your other css has the same style, which overwrite?
Comment: Thanks CocoSkin. Looking at firebug I don't see that. However, requirements change, as did the requirement that needed this style such that I no longer need to introduce the new style so going to stop looking for a solution.
Answer: Just to eliminate a possible cause of your problem: if you have enabled CSS aggregation then you must clear the cache before changes to CSS files become active.
Comment: Thanks for the tip Pierre. I've done that and it is not the problem.

Which file should my style be in


How to add views exposed filter blocks into views

Question: I am trying to move a views exposed filter into a custom block, and then add it back to the views header. The reason for this is because I would like to intersperse the filter with other blocks/markup in the views header. When I selected the option to turn the filter into a block, it does show in the Block UI, but not as an option to add to the view header.
Is this possible in views?
Comment: You say you want to add it to the header with other blocks. How were you planning on adding the other blocks to the view header? It should work the same way for the exposed filter block.
Comment: @rooby - thats what I thought too, but it didn't work. As I mentioned, the filter block doesn't show as an option as a block to insert into the views header.
Answer: Add the following function in your template.php
function THEMENAME_render_block($module, $delta, array $options = array()){
  $default_options = array(
    'title' => '<none>',
    'region' => -1,
  );

  $options = array_merge($default_options, $options);

  $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
  if($block) {
    $block = block_load($module, $delta);
    $block->title = $options['title'];
    $block->region = $options['region'];
    $blocks = array($block);
    $rblocks = _block_render_blocks($blocks);
    $render_array = _block_get_renderable_array($rblocks);
    return drupal_render($render_array);
  }
  return "";
}

then in your views header render the block like so
<?php print THEMENAME_render_block('<moduleName>', 'delta', array('title' => t('Filter Title'))); ?>

For this you must have views php module enabled if you want to render the block from views header or else you can use tpl file to render the block in the header as @rooby suggested.
Comment: It would be preferable to override views-view.tpl.php instead of adding PHP via the views php module. If you're already writing custom code you may as well do it all in code and not put code in the DB.
Comment: @user1015214 you are right. views  php kills site site performance as the code are not get cached. this is the reason php module removed from drupal 8 core. You can use the same function in your views tpl instead.
Comment: Passing in the title and region options like that seems a bit strange since you can configure those things via the block UI. If you really want to be able to override those options it should be done only if they are present and if they are not present it should use the options saved for that block in the DB. Otherwise the person using this snippet might not know why their block settings are being ignored.
Comment: @rooby Agreed, Title and regions are optional arguments You can pass it or not.
Comment: @ShabirA.- adding PHP into the database is not an option for me. I've learned the hard way that that is a really bad idea and makes things hard to debug. I definitely can render the blocks in code in the views tpl, I just figured there should be a way of rendering it via the UI, since it its a Drupal block.
Comment: @ShabirA.: They are optional for this function but then you set defaults that override what is stored in the DB always. It's the $default_options part that causes the issue.


I have an error when create edit form in magento

Question: Fatal error: Call to a member function setData() on a non-object in C:\xampp\htdocs\magento3\app\code\core\Mage\Adminhtml\Block\Widget\Form\Container.php on line 129

Edit.php
    <?php
class Magecom_Magecomslider_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
    {
        parent::__construct();

        $this->_objectId = 'id';
        $this->_controller = 'adminhtml_magecomslider';
        $this->_mode = 'edit';

        $this->_updateButton('save', 'label', Mage::helper('magecom_magecomslider')->__('Save Image'));
        $this->_updateButton('save', 'id', 'save_button');
        $this->_updateButton('delete', 'label', Mage::helper('magecom_magecomslider')->__('Delete Image'));

        if( $this->getRequest()->getParam($this->_objectId) ) {
            $magecomSlider = Mage::getModel('magecom_magecomslider/magecomslider')
                ->load($this->getRequest()->getParam($this->_objectId));
            Mage::register('magecomSlider', $magecomSlider);
        }
    }

    public function getHeaderText()
    {
        return Mage::helper('magecom_magecomslider')->__('Add Image');
    }
}

Form.php
    <?
class Mage_Adminhtml_Block_Magecom_Magecomslider_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {exit("asd");exit("asd");
        $magecomSlider = Mage::registry('magecomSlider');
        //$product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
        //$customer = Mage::getModel('customer/customer')->load($review->getCustomerId());
        $magecomslider = Mage::getModel('magecom_magecomslider/magecomslider')->load($this->getRequest()->getParam('id'));

        $form = new Varien_Data_Form(array(
            'id'        => 'edit_form',
            'action'    => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))),
            'method'    => 'post'
        ));

        $fieldset = $form->addFieldset('magecomslider', array('legend' => Mage::helper('magecom_magecomslider')->__('Add Image'), 'class' => 'fieldset-wide'));

        $fieldset->addField('magecomslider', 'image', array(
            'label'     => Mage::helper('magecom_magecomslider')->__('Image'),
            'text'      => 'magecomslider',
        ));

        $form->setUseContainer(true);
        $form->setValues($review->getData());
        $this->setForm($form);
        return parent::_prepareForm();
    }
}

MagecomsliderController.php
<?php
class Magecom_Magecomslider_Adminhtml_MagecomsliderController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->_title($this->__('Magecom Slider'));

        $this->loadLayout();
        $this->_setActiveMenu('magecom_magecomslider');
        $this->_addBreadcrumb(Mage::helper('magecom_magecomslider')->__('Magecom Slider'), Mage::helper('magecom_magecomslider')->__('Magecom Slider'));
        $this->renderLayout();

    }
    public function massAddAction()
    {
        $productIds = $this->getRequest()->getParam('product');
        if (!is_array($productIds)) {
            $this->_getSession()->addError($this->__('Please select products.'));
        } else {
            if (!empty($productIds)) {
                try {
                    $countItems = count($productIds);
                    if($countItems>2 || $countItems<2)
                    {
                        $this->_getSession()->addError($this->__('You should select only 2 products.'));
                    }else{
                        $slider_items = Mage::getModel('magecom_magecomslider/magecomslider');
                        $collection_slider_items = $slider_items->getCollection();
                        $collection_slider_items_count = $collection_slider_items->count();
                        if($collection_slider_items_count==2)
                        {
                            $this->_getSession()->addError($this->__('Sliders exists.'));
                        }else{
                            foreach ($productIds as $productId) {
                                $data = array('product_id' => $productId);
                                $model = Mage::getModel('magecom_magecomslider/magecomslider');
                                $model->setData($data);
                                $model->save();
                            }
                            $this->_getSession()->addSuccess(
                                $this->__('Products added to the slideshow.')
                            );
                        }
                    }
                } catch (Exception $e) {
                    $this->_getSession()->addError($e->getMessage());
                }
            }
        }
        $this->_redirect('*/*/index');
    }
    public function gridAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
    public function deleteAction()
    {
        try {
            $slider_items = Mage::getModel('magecom_magecomslider/magecomslider');
            $collection_slider_items = $slider_items->getCollection();
            foreach($collection_slider_items as $item)
            {
                $item->delete();
            }
            $this->_getSession()->addSuccess(
                $this->__('Sliders deleted successfully.')
            );
        }catch (Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        }
        $this->_redirect('*/*/index');
    }
    public function editAction()
    {
        $this->loadLayout();
        $product_id = $this->getRequest()->getParam('id');

        $slider_items = Mage::getModel('magecom_magecomslider/magecomslider');
        $collection_slider_items = $slider_items->getCollection();
        $collection_slider_items_count = $collection_slider_items->count();
        if($collection_slider_items_count==2)
        {

        }else{
            $this->_getSession()->addError($this->__('Please select products for slider.'));
        }
        $this->renderLayout();
        //exit($product_id);
    }
    public function saveAction()
    {
        exit("Save");
    }
}

And look please in Form.php exit does not work, i think its mean what this form not called, i dont know why.
magecomslider.xml
<?xml version="1.0"?>
<layout version="0.1.0">
    <adminhtml_magecomslider_index>
        <reference name="content">
            <block type="magecom_magecomslider/adminhtml_magecomslider" name="magecomslider.grid_container" />
        </reference>
    </adminhtml_magecomslider_index>

    <adminhtml_magecomslider_new>
        <update handle="adminhtml_magecomslider_edit"/>
    </adminhtml_magecomslider_new>

    <adminhtml_magecomslider_edit>
        <reference name="content">
            <block type="magecom_magecomslider/adminhtml_edit" name="magecomslider.edit" />
        </reference>
    </adminhtml_magecomslider_edit>
    <adminhtml_magecomslider_grid>
        <block type="core/text_list" name="root" output="toHtml">
            <block type="magecom_magecomslider/adminhtml_magecomslider" name="magecomslider.grid_container" />
        </block>
    </adminhtml_magecomslider_grid>
    <adminhtml_magecomslider_edit>
        <reference name="content">
            <block type="magecom_magecomslider/adminhtml_edit" name="magecomslider.form_container" />
        </reference>
    </adminhtml_magecomslider_edit>
</layout>

Magecomslider.php - model
<?php
class Magecom_Magecomslider_Model_Magecomslider extends Mage_Core_Model_Abstract
{
    protected function _construct()
    {
        $this->_init('magecom_magecomslider/magecomslider');
    }
}

Magecomslider.php - resourse model
<?php
class Magecom_Magecomslider_Model_Resource_Magecomslider extends Mage_Core_Model_Mysql4_Abstract
{
    protected function _construct()
    {
        $this->_init('magecom_magecomslider/magecomslider', 'id');
    }
}

Collection.php
<?php
class Magecom_Magecomslider_Model_Resource_Magecomslider_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    protected function _construct()
    {
        $this->_init('magecom_magecomslider/magecomslider');
    }
}

Comment: could you show me the model files in your module
Comment: Sure, i am update question
Answer: I had the same error in edit.php file
now inside _construct() function
Add this line :
$this->_blockGroup = 'your block group here';

hope this will work
thanks
Answer: Double check your block name here :  edit.php
$this->_blockGroup = 'your_block_group/group_name';
if you did not have this line, add this to your edit.php
enjoy coding....
thanks
Comment: Too low quality of answer. Please, try to describe reason to 'check block name', add some explanation.


Can we expect $g(f\ast h)= gf \ast gh$ for some $g\in C_{c}^{\infty}(\mathbb R)$?

Question: Let $f,g:\mathbb R \to \mathbb C$ be nice functions so that their convolution make sense.

My question: Is it possible to choose $0\neq g\in C_{c}^{\infty}(\mathbb R)$ (= the space of smooth functions with compact support) so that
  $g(f\ast h)= gf \ast gh$? Or atleast: $|g(f\ast h)| \leq C |gf \ast gh|$ for some constant $C$?  Or $g(f\ast h)= gf \ast h$?

Edit: Let $f,h \in L^{p}(\mathbb R)\cap C_{0}(\mathbb R), (2\leq p \leq \infty),$ where $C_{0}(\mathbb R)$ is the space of continuous functions vanishing at infinity.
Or even if we can choose $g=g_{1}g_{2}$ so that $g(f\ast h)= g_{1}f \ast g_{2}h$ for $g_{1}, g_{2}\in C_{c}^{\infty}(\mathbb R)$ is also o.k.($g_{1}, g_{2}$ can be depends on $f$ and $h$)
Comment: Is $g$ allowed to depend on $f,h$? What exactly do you mean by "nice"? If $f,h$ are compactly supported, this is certainly possible (if $g$ is allowed to depend on $f,h$).
Comment: I will write the proof this evening. I think I can also show that one can not choose such a $g$ in general. I will also write my idea for that this evening.
Comment: @PhoemueX; Thanks ; I have edited my question; and yes $g$ is allowed to be depend on $f$ and $h.$
Comment: @PhoemueX; would you please write the partial answer(in special cases of $f$ and $h$) as you are saying it can be done; (I think it could be helpful, see also related [question](http://math.stackexchange.com/questions/1229715/can-we-choose-g-so-that-g-widehatf3-vee-lp-leq-c-g-1); actually current one occur to me while solving [this](http://math.stackexchange.com/questions/1229715/can-we-choose-g-so-that-g-widehatf3-vee-lp-leq-c-g-1) ); Thanks.
Answer: First of all, I don't really understand why you assume $f,h\in L^{p}\left(\mathbb{R}\right)\cap C_{0}\left(\mathbb{R}\right)$
with $p\in\left[2,\infty\right]$, since in general the convolution
$f\ast h$ will not be well-defined with these assumptions, consider
e.g.
$$
f\left(x\right)=h\left(-x\right)=\frac{1}{\ln x}\cdot\chi_{\left(e,\infty\right)}\left(x\right),
$$
suitably modified on $\left(-10,10\right)$ to make it continuous.
For $x<0$, this yields
$$
\int\left|f\left(y\right)h\left(x-y\right)\right|\, dy\geq\int_{\left(1000,\infty\right)}\frac{1}{\ln y}\frac{1}{\ln\left(y-x\right)}\, dy=\infty.
$$
Anyway, if $f,h$ have compact support, let $K_{1}:={\rm supp}\, f$
and $K_{2}:={\rm supp}\, h$ as well as $K_{3}:=K_{1}+K_{2}$. Since
$f,h$ have compact support, we have $f,h\in C_{c}\left(\mathbb{R}\right)$.
Any $x\in\mathbb{R}$ with $0\neq f\ast h\left(x\right)$ satisfies
$$
0\neq f\ast h\left(x\right)=\int f\left(y\right)\cdot h\left(x-y\right)\, dy,
$$
so that there is some $y\in\mathbb{R}$ with $y\in K_{1}$ and $x-y\in K_{2}$.
Hence, $x=\left(x-y\right)+y\in K_{2}+K_{1}$, i.e. ${\rm supp}\left(f\ast h\right)\subset K_{1}+K_{2}$.
Now, choose any $g\in C_{c}^{\infty}\left(\mathbb{R}\right)$ with
$g\equiv1$ on $K_{1}\cup K_{2}\cup\left(K_{1}+K_{2}\right)$. This
implies
$$
g\cdot\left(f\ast h\right)=f\ast h=\left(gf\right)\ast\left(gh\right),
$$
since $g\equiv1$ on the supports of all involved functions.
Finally, I think the claim is false in general. To see this, let
$$
f\left(x\right)=h\left(x\right)=e^{-x^{2}}
$$
for $x\in\mathbb{R}$. Then $f,h\in L^{p}\left(\mathbb{R}\right)\cap C_{0}\left(\mathbb{R}\right)$
for all $p\in\left(0,\infty\right]$. Now assume that there is some
$g\in C_{c}^{\infty}\left(\mathbb{R}\right)$ with
$$
g\cdot\left(f\ast h\right)=\left(gf\right)\ast\left(gh\right).
$$
Note that $f\ast h\left(x\right)=\int f\left(y\right)\cdot h\left(x-y\right)\, dy>0$
for all $x\in\mathbb{R}$, since the integrand is everywhere positive.
Thus, the support of the left-hand side is ${\rm supp}\, g$.
By the Titchmarsh convolution theorem (see http://en.wikipedia.org/wiki/Titchmarsh_convolution_theorem ;
note that if you require $g\geq0$, the following is clear and we do not have
to invoke that theorem), we have
\begin{eqnarray*}
\inf\left[{\rm supp}\, g\right] & = & \inf\left[{\rm supp}\left(gf\right)\ast\left(gh\right)\right]\\
 & = & \inf\left[{\rm supp}\left(gf\right)\right]+\inf\left[{\rm supp}\left(gh\right)\right]\\
 & = & \inf\left({\rm supp}\, g\right)+\inf\left({\rm supp}\, g\right)\\
 & = & 2\cdot\inf\left({\rm supp}\, g\right),
\end{eqnarray*}
which implies
$$
\inf\left[{\rm supp}\, g\right]=0.
$$
The same statement holds with "$\sup$" instead of "$\inf$",
i.e. $\sup\left[{\rm supp}\, g\right]=0$. But this means ${\rm supp}\, g\subset\left\{ 0\right\} $,
in contradiction to $g\neq0$ and $g\in C_{c}^{\infty}\left(\mathbb{R}\right)$.
Of course, it could still be possible that one can choose $g$ with
$$
\left|g\cdot\left(f\ast h\right)\right|\lesssim\left|\left(gf\right)\ast\left(gh\right)\right|.
$$
I will have to think about that.
Answer: Suppose that such a $g$ exists :
$$g(f*g)=gf*gh\text{ for all } f,h\in C^{\infty}_c(\mathbb{R})$$
Then we have for each $x\in\mathbb{R}$ :
$$g(x)\int f(t)h(x-t)dt=\int g(t)f(t)g(x-t)h(x-t)  $$
i.e. :
$$\int(g(x)-g(t)g(x-t))f(t)h(x-t)dt=0 $$
Set for all $x$, $\psi_x(t):=g(x)-g(t)g(x-t)$. Then $\psi_x$ is a function in $C^{\infty}(\mathbb{R})$ verifying :
$$\int\psi_x(t)f(t)h(x-t)dt=0 $$
Taking $h$ a function wich is $1$ on $x-Supp(f)=\{x-y|y\in Supp(f)\}$ and $0$ at infinity (you can always construct such a function) you get that for each $f\in C^{\infty}_c(\mathbb{R})$ :
$$\int\psi_x(t)f(t)dt=0 $$
Suppose now that $\psi_x\neq 0$, for instance : $\psi_x(x_0)>0$ (the case $<0$ works the same way), then you can find a little open set $]x_0-\delta,x_0+\delta[$ such that $\psi_x(t)>0$ for $t$ in it. Take $f>0$ a non-zero continuous function such that $f(t)=0$ for $t\leq x_0-\delta$ and $t\geq x_0+\delta$. Then :
$$\int\psi_x(t)f(t)dt>0$$
Because it is the integral of a positive continuous function over  $]x_0-\delta,x_0+\delta[$, this contradicts the fact that :
$$\int\psi_x(t)f(t)dt=0 $$
This being true for each $x\in \mathbb{R}$ we have shown that :
$$g(x)=g(t)g(x-t)\text{ for all } x,t\in\mathbb{R} $$
In particular for all $x$ :
$$g(x)=g(-1)g(x+1)=...=g(-1)^ng(x+n) $$
But because $g$ itself is assume to be of compact support you get that $g(x+n)=0$ for $n$ big enough and hence $g(x)=0$. It follows that $g$ must be null.


Gstreamer Playing a raw h.264 stream from a USB source (timestamp issues)

Question: I'm dealing with a live video source (drone wireless video receiver) that outputs a raw h.264 video stream over USB. My goal is to integrate it into QGroundStation in Android, which has a GStreamer pipeline.
I have dumped a slice of the received USB data to a file, which is perfectly playable with vlc using the following command:
vlc -c dump.bin --demux h264

However, if I play it back using this GStreamer pipeline, the playback speed is too high (like x10)
gst-launch-1.0.exe filesrc location="dump.bin" ! h264parse ! avdec_h264 ! autovideosink

I'm using appsrc to push the USB data into the QGroundControl pipeline. The video plays, but lots of frames are dropped and gstreamer complains about packets dropped because frames are too late.
[...]
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.404134207)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.403025291)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.401385832)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.400435290)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.399607540)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.398911040)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.398131998)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.397308623)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.396620290)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.395761040)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.395125498)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.394197123)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.393461831)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.392803831)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.391983373)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.391033998)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.389664914)
    W QGroundControl Daily: GStreamerAPILog: <amcvideodec-omxrkvideodecoderavc18> Frame is too late, dropping (deadline -0:00:00.388862831)
    W QGroundControl Daily: GStreamerAPILog: <h264parse53> broken/invalid nal Type: 1 Slice, Size: 38639 will be dropped
    W QGroundControl Daily: GStreamerAPILog: <h264parse53> broken/invalid nal Type: 1 Slice, Size: 37460 will be dropped
    W QGroundControl Daily: GStreamerAPILog: <h264parse53> broken/invalid nal Type: 1 Slice, Size: 46566 will be dropped
    W QGroundControl Daily: GStreamerAPILog: <h264parse53> broken/invalid nal Type: 1 Slice, Size: 36055 will be dropped
    W QGroundControl Daily: GStreamerAPILog: <h264parse53> broken/invalid nal Type: 1 Slice, Size: 43397 will be dropped
[...]

After closer inspection of my dump, I realized that the stream is lacking pts and dts information (which seems to be usual in baseline h.264 streams)
ffprobe -show_frames dump.bin

[PACKET]
codec_type=video
stream_index=0
pts=N/A
pts_time=N/A
dts=N/A
dts_time=N/A
duration=48000
duration_time=0.040000
convergence_duration=N/A
convergence_duration_time=N/A
size=1843
pos=0
flags=K_
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=N/A
pts_time=N/A
dts=N/A
dts_time=N/A
duration=48000
duration_time=0.040000
convergence_duration=N/A
convergence_duration_time=N/A
size=16851
pos=1843
flags=K_
[/PACKET]

But apparently, the duration information is there.
The USB endpoint reads 512-byte chunks (due to the USB Hi-Speed max. payload size for a bulk endpoint), and some transfers are smaller (400+ bytes long). I have no way to detect the beginning/end of NALs since it's an opaque continuous byte stream. (video/x-h264, stream-format=(string)byte-stream, alignment=none)
So I built an appsrc to push the video stream to the pipeline and tried to blindly timestamp the buffers like this:
void _startFeed(GstElement *source, guint size, gpointer pContext) {
(void)pContext;

GstBuffer *pBuffer;
GstFlowReturn ret;
GstMapInfo map;
guint8 *pRaw;

GstClock *pClk = gst_element_get_clock(gPipeline);
GstClockTime absolute = gst_clock_get_time(pClk);
GstClockTime base = gst_element_get_base_time(gPipeline);
gst_object_unref(pClk);

pBuffer = gst_buffer_new_and_alloc(bufferSize);

// Timestamp the buffers
GST_BUFFER_PTS(pBuffer) = absolute - base;
GST_BUFFER_DTS(pBuffer) = GST_BUFFER_PTS(pBuffer);

gst_buffer_map(pBuffer, &map, GST_MAP_WRITE);

pRaw = (guint8 *)map.data;

fifo_pull(pRaw, size);  // This pulls up to 'size' bytes from the USB FIFO and copies it to pRaw

gst_buffer_unmap(pBuffer, &map);

g_signal_emit_by_name(gAppSrc, "push-buffer", pBuffer, &ret);

gst_buffer_unref(pBuffer);
}

... but still no luck ...
I have had limited success by using the following pipeline that encodes the h.264 stream into RTP payloads and then decodes it with a caps filter specifying the target framerate:
gst-launch-1.0.exe filesrc location="dump.bin" ! video/x-h264, stream-format=(string)byte-stream, alignment=none ! h264parse ! rtph264pay ! rtpjitterbuffer ! rtph264depay ! video/x-h264, stream-format=byte-stream, alignment=nal, framerate=(fraction)30/1 ! h264parse ! avdec_h264 ! autovideosink

I could build that into QGroundControl in C++ but I don't think it's the right approach and I should not make any assumptions about the target framerate since in this case it's 30 fps, but it may change dynamically.
So, my questions are:

What would be the right approach to getting the video playing at the right speed without any frame drops?
Is it reasonable or possible to ask GStreamer to generate the PTS/DTS (there are no B-frames, so PTS should be equal to DTS) based on the duration information of the packets using the standard pipeline?

Update::

I have tried a known workaround for interpolating PTS from DTS +
duration described here but in my case, neither PTS nor DTS
are available in the stream, so it didn't make any difference.
The correct framerate for this particular video dump should be 29.97 fps (NTSC). I have a running counter in the video image to verify it.
As you can see in my ffprobe output, the duration_time information appears as 0.04 s, which corresponds to 25 fps, which puzzles me.
Surprisingly, VLC plays the video at the right speed, and correctly guesses the framerate as 29.97 fps (as per the video codec info window that you get pressing Ctrl+J)
I've noticed that rtph264pay will generate the missing timestamps, but the guessed framerate is 25 fps, as the duration_time field of the packets suggests
Comment: `I have no way to detect the beginning/end of NALs since it's an opaque continuous byte stream.` This is almost certainly an AnnexB stream, so detecting NALu should just be a matter for looking for start codes. Ideally, the stream will have AUDs, so the byte sequence 0x00000109xx (where xx can be almost anything) Will give you the start of a frame.
Comment: Thanks. Yes, that seems to be the case and I can confirm these sequences are present. But unfortunately the decoder doesn't seem to care about the data being NAL-aligned or not. So apparently this won't help much. But thanks for pointing it out.
Answer: I used an h.264 stream analyzer and realized that this particular stream has no VUI information in the SPS NALs, (therefore no time_tick or time_scale info that could be used by the parser to calculate PTS).
What worked for me is to set the property "sync" = false on the sink to render the frames as soon as they arrive. Not ideal, but I can live with it.


Return individual value from a D3 color range to create legend

Question: I have code for 5 colors:
var color = d3.scaleQuantize()
    .range([
        'rgb(237,248,233)',
        'rgb(186,228,179)',
        'rgb(116,196,118)',
        'rgb(49,163,84)',
        'rgb(0,109,44)'
    ]);

I want to grab each one of those values in order to color a legend.
I'm trying things like this but it's not working:
.style('fill', function (d, i) {
    return color.range([0]);
});

How do I reference each item in the color range so I can color a block of legend that way?
Thanks!
Edit: Sorry I left the console.log piece there that I was testing the code with, now corrected.
Answer: you can use function variable of i, these i variable follows the sequence.
For example
.style("fill", function (d,i) {
                    return color(i);//or color.range(i);

Comment: Thanks Umesh, I figured it out at same time!  Clearly I over complicated it.
Answer: I think I figured it out.  d3.scaleQuantize() returns a value if you input a number in parentheses.  However, just doing color like it was a regular array gave me each color individually, which could be fed into the legend.
.style("fill", function (d, i) {return d};)


How do I select a row in MySQL that contains multiple values?

Question: I have a MySQL table that looks like this:
Table: Designer
  id: integer
  name: String
  gallery: string

The gallery row can contain a string value like 23,36,45
Now I want to do a query similar to this:
SELECT * FROM Designer WHERE gallery = '36'

I know I kan use LIKE, but that is not precices enough. That could return both 36 and 136.
I also know I could create another table which links designer and gallery. But since this is not going to be a huge table, I'm adding the foreign gallery ID Key to the gallery row. And I'm lazy right now ;)
So how can I select a row that has the number 36?
UPDATE
Ok, since I'm getting nailed for poor design (yes I know it was), I See the obvious now.
A designer can have many galleries, but a gallery can only belong to one designer.
Therefore I only need to add designer ID as a foreign key to the gallery table.
Simple. But not always logical when it's 3AM and you've been workign for 15 hours ;)
Comment: **Never** have a row in MySQL that contains multiple values. But make another table that contains multiple rows, linked to this row.
Comment: **CAN WHOEVER IS DOWNVOTING ANSWERS STOP DOING THAT?**
Comment: hmm... I'm not sure who is downvoting all the answers here....
Comment: @Col - Yeah, I know. But I'm also lazy right now :)
Answer: If you have to do that you have poorly designed your tables.
One designer can have got many galleries and a gallery belong to one designer means you must create a foreign key 'designer' in your 'gallery' table, and your request will be
SELECT *
FROM Designer
INNER JOIN Gallery
ON Gallery.id = 36
AND Designer.id = Gallery.designer

Comment: No, the gallery can only belong to one designer. But a designer can hve many galleries. See my update.
Comment: I think it's an overkill to use INNER JOIN here. Much easier just to do `SELECT * FROM Designer, gallery WHERE designer.id = gallery.fk_designer_id`.
Comment: It's about join syntax, mine is recommended http://dev.mysql.com/doc/refman/5.1/en/join.html otherwise this is the same query.
Answer: I also agree that this is poorly designed table structure but here is the answer
SELECT * FROM Designer where FIND_IN_SET(36,gallery)

Comment: Someoe down voted the answer, if the answer works, please vote it up :)
Answer: You really shouldn't store your data like that since it makes queries horribly inefficient. For that particular use case, you can (if you don't care about performance) use:
select * from designer
    where gallery like '36,%'
       or gallery like '%,36'
       or gallery like '%,36,%'
       or gallery = '36'

This will alleviate your concerns about partial matches since something like 136 will not match any of those conditions but 36 in any position will match.

However, despite your protestations to the contrary, what you should do is re-engineer your schema, something like:
designer:
    id             integer primary key
    name           varchar(whatever)
designer_galeries:
    designer_id    integer foreign key references designer(id)
    gallery        string
    primary key    (designer_id,gallery)

Then your queries will be blindingly fast. One of the first things you should loearn is to always design your schema for third normal form. You can revert to other forms for performance once you understand the trade-offs (and know how to mitigate problems) but it's rarely necessary unless you database is horribly convoluted.
Comment: I'm pretty competent i DB design and I **know** this was bad design. But I was to tired to think (and didn't use pen and paper when designing). So yes, adding foreign key in gallery table is by far the best solution!
Comment: @Steven, you _can_ use the first solution if you don't care that much about performance. For example, it's perfectly acceptable if you know your table will never exceed 100 rows and won't ever be hit with more than a few concurrent queries since you probably don't _need_ professional DBMS performance in that case. That's YAGNI kicking in. It's just that, in my experience, tables never stay as small as you expected :-)
Comment: he,he - you are right.  This is for displaying fashion designers on a website. Although I have around 60 designers, many ppl are opening the page to view galleries and brows designer info. During off season, I'll maybe have 10-20 a week. But during fashion week, I might have 2.000 a day :)
Answer: You can use regular expressions in your WHERE clause instead.
http://dev.mysql.com/doc/refman/5.1/en/regexp.html
SELECT * FROM Designer WHERE gallery REGEXP "(,|^)(36)(,|$)"


Just Intonation > Equal Temperament "Consonance and Dissonance"?

Question: So for months now I'm becoming increasingly frustrated with this Just Intonation versus Equal Temperament, so maybe with this question we can nip it in the bud. If we could refrain from "complex mathematics" which i have trouble comprehending and utilize language and simple math, it would be most efficient.
I will firstly articulate my goal behind asking this question..
I have produced with the help of you good people an interval ranking. The purpose of this interval ranking is solely to tell me what intervals within an octave are most consonant to dissonant from most to least.
The reason i sought this information is so that i can build a chord with the exact desired level of consonance and/or dissonance that i preferred so that when i build a chord progression, i have entire mathematical control over the result. Wrong or right, this is my absolute goal.
The very specific question follows..
If i am using the interval ranking chart for the stated above purpose, does this ranking of intervals from most consonant to dissonant apply to composition in 12tet or when composing in 12tet do the degrees of consonance and dissonance of intervals in just intonation differ in 12tet. I do not mean in their numerical properties but their general sonic properties.
Alternatives..
If this is not the case..

How can i translate the interval ranking from Just Intonation to 12tet, so that i have a list of intervals from most consonant to dissonant applicable to 12tet?

The desired end result of this question example..

Unison = 1st most consonant interval in an octave.
Octave = 2nd most consonant interval in an octave.
Perfect Fifth = 3rd most consonant interval in an octave.
Perfect Fourth = 4th most consonant interval in an octave.
Major Sixth = 5th most consonant interval in an octave.
Major Third = 6th most consonant interval in an octave.
Minor Third = 7th most consonant interval in an octave.
Minor Sixth = 8th most consonant interval in an octave.
Minor Seventh = 9th most consonant interval in an octave.
Major Second = 10th most consonant interval in an octave.
Major Seventh = 11th most consonant interval in an octave.
Minor Second = 12th most consonant interval in an octave.
Tritone = 13th most consonant interval in an octave.

I mean this in the most polite manner possible, i am looking for a very straight cut answer. I do not require complex mathematics or incredibly detailed answers. I am just seeking to have a list of intervals within an octave from most consonant to least consonant applicable to 12tet composition. Ideally the desired end result of this question i displayed would be the perfect format to answer this question.
Tremendous thanks to you.
EDIT!!
There seems to be quite a few comments stating that it is impossible to rank 12 intervals in an octave by most consonant to dissonant so let me elaborate.
If a chord progression is developed through tension and release, that tension and release is accounted for by a combination of intervals (a chord) that through each bar go from dissonant (tension) to consonance (rest). If we acknowledge that a chord could be considered to be multiple intervals at work simultaneously, how can we absolutely deny their individual degrees of consonance and dissonance within context of a chord progression? The denial is absolutely baffling to me. It is obvious that the interval of a perfect fifth is more consonant than the interval of a minor second, so evidently the intervals do have their individual degree of consonance/dissonance relative to the root. I will even assume that maybe some of you good folks are jumping in the gun in your answers as opposed to what im specifically asking which revolves around interval to interval relationship and not for example a chord progression. I am not asking how this method would be applicable to a progression, i am very specifically asking what intervals are most consonant to dissonant relative to the root (interval) in 12tet. Nothing more and nothing less.
I also saw a comment stating "what may sound consonant to one listener may be dissonant to another". I think it is undeniable that any listener on planet earth would find an octave more dissonant than a minor second. So evidently a consonance/dissonance ranking does exist and i will paste below my actual ranking which i think some confused my example one for a real ranking.
My question is, is the ranking below applicable to 12tet, not by its numerical values which i understand differ slightly, but the general sound.
I hope this helps.

Unison = 1:1 Perfect Consonance (1st note of an octave)
Octave = 2:1 Perfect Consonance (13th note of an octave)
Perfect Fifth = 3:2 Perfect Consonance (8th note of an octave)
Perfect Fourth = 4:3 Dissonant when the bass note (6th note of an octave)
Major Sixth = 5:3 Imperfect Consonance (10th note of an octave)
Major Third = 5:4 Imperfect Consonance (5th note of an octave)
Minor Third = 6:5 Impefect Consonance (4th note of an octave)
Minor Sixth = 8:5 Imperfect Consonance (9th note of an octave)
Minor Seventh = 9:5 Dissonant (11th note of an octave)
Major Second = 9:8 Dissonant (3rd note of an octave)
Major Seventh = 15:8 Dissonant (12th note of an octave)
Minor Second = 16:15 Dissonant (2nd note of an octave)
Tritone = 7:5 Dissonant (7th note of an octave)
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/98689/discussion-on-question-by-seery-just-intonation-equal-temperament-consonance).
Answer:
I have produced with the help of you good people an interval ranking.
  The purpose of this interval ranking is solely to tell me what
  intervals within an octave are most consonant to dissonant from most
  to least.
The reason i sought this information is so that i can build a chord
  with the exact desired level of consonance and/or dissonance that i
  preferred so that when i build a chord progression, i have entire
  mathematical control over the result.

Your table doesn't tell you anything about what the intervals sound like. It is just your personal definition of how they are ranked according to some (not very well defined) criterion.
Many people will disagree that such an "absolute" ranking even exists, and those who believe it does exist will probably disagree with you about the exact order.

Wrong or right, this is my absolute goal.

That may be your goal, but it doesn't mean it is possible to do it.
Don't forget the quote attributed (probably incorrectly) to Einstein: "Insanity is repeating the same action over and over again, but hoping that next time you will get a different outcome."
You seem to be trying to construct a "theory of music" which ignores the facts that (1) music is sound that is  perceived by humans and (2) the way it is perceived is a learned social construct, not something that is innate at birth.
By my definition, what you are doing might be interesting as an exercise in logic or mathematics (though most of the "mathematics" invented by music theorists is trivial and uninteresting from a mathematician's viewpoint), but whatever it is, it's not "music" by any common-sense definition of the word.
FWIW, after 50+ years of playing and writing music (which actually gets played and listened to by other people apart from myself) I don't even think the terms "consonance" and "dissonance" have any practical use at all in a general "theory of music". The theories that do use those terms are only an approximate description of the sort of music that was made in some limited situations - limited to certain groups of people, and during certain historical periods.
Comment: In my post edit i pasted the actual interval ranking as opposed to the one you saw which was for example purposes and not a ranking itself. I am aware i am insisting on this topic and it is because despite claims that it is not possible, i truly believe it is and eventually i will articulate it and have made progress in this topic that was initially deemed unlikely to obtain. What sound is to me is frequencies and music is the manipulation of those frequencies. Anything relevant to humans and sound is taste and art, not science. A baby can enjoy music before it is exposed to social construct.
Answer: To keep it simple as you requested, let's just take another look at the well known 12-TET curve from Sethares' site, slightly edited - I've added the curve 'values' at each 12-TET interval.

The values I've added are simply the number of pixels of the line from the top of the image - but that's fine for the purposes of checking the ranking - and for any comparison purposes, because the dissonance 'unit' is arbitrary anyway.
Lets check those numbers against your ranking:

Unison = 0
Octave = 0
Perfect Fifth = 29
Perfect Fourth = 50
Major Sixth = 54
Major Third = 82
Minor Third = 93
Minor Sixth = 101
Minor Seventh = 73
Major Second = 147
Major Seventh = 148
Minor Second = 293
Tritone = 101

We can see that the numbers there aren't in order regarding the minor seventh and tritone, so we can say that your ranking does not seem to be right according to the definition of consonance by which that graph was created. If you want to know more about that, Sethares' site has a good explanation.
If by 'consonance', you aren't referring to the Plomp/Levelt idea of consonance but something else, you need to be clear what definition you mean.

The reason i sought this information is so that i can build a chord with the exact desired level of consonance and/or dissonance that i preferred so that when i build a chord progression, i have entire mathematical control over the result. Wrong or right, this is my absolute goal.

If you really want to get that right, I would suggest that you don't use a ranking at all, but use the curve values directly. This is because adding the rankings together for the different intervals that would be found between notes in a chord might not give you the same equivalent overall levels of comparative dissonance as if you were to add together the curve values.
If you want to calculate a more precise curve that has values that are better than the 'pixel' values here, again Sethares' site has a lot of information - e.g. the code at http://sethares.engr.wisc.edu/comprog.html
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/98690/discussion-on-answer-by-topo-morto-just-intonation-equal-temperament-consonan).
Answer: It is not possible to have such a range of single intervals as your concept of dissonance and consonance is not fully congruate with the theory that has been developed in thousands of years not only by mathematical and physical phenomenas but also by the position of 2 tones in a chord with other tones and also in a chord progression.
2 examples:

The fourth was considered as consonant in the time of the fourth parallel organum.
It is still consonant in a major triad with the octave.

But the fourth can be considered as dissonant in a I46 or V4 chord as sustained 4th resolving in a consonant 3rd.

The minor 6th (consonant) can be the enharmonic exchange  of an augmented 5th which sounds dissonant and has an enormous tension to be resolved in a 3rd of the fourth.

But you probably want to create a mathematical theory outside of a concept of classical harmony.
Than you have to look up in Hindemith
http://www.hindemith.info/en/life-work/biography/1933-1939/work/principles-and-categories/
https://notingharmonics.wordpress.com/2015/03/11/hindemith-on-intervals/
etc.
or you can listen the intro of my first brass-quartet that operates with major 7th and augmented 5th chords. I think they are all pretty consonant.
Comment: many thanks for your contribution and links. I will check them out now. Great job too with your recording, sounds pretty good!
Answer: This is too lengthy for a comment, so I'm posting it as an answer.  The point, however, is to challenge some assumptions.
First, an actual answer:

How can i translate the interval ranking from Just Intonation to 12tet, so that i have a list of intervals from most consonant to dissonant applicable to 12tet?

The 12-tone intervals are approximations of the just intervals, so their consonance and dissonance is roughly equivalent to that predicted by the corresponding just ratios.
An assumption challenge:

If a chord progression is developed through tension and release, that tension and release is accounted for by a combination of intervals (a chord) that through each bar go from dissonant (tension) to consonance (rest).

To the extent that a chord progression is developed through tension and release, it is not entirely related to the internal harmonic dissonance of each chord.  That is, the degree of a chord's dissonance cannot be determined solely from the chord's intervals.  To illustrate this, consider the chord progression C major, F major, G major, C major.  Each of these chords is a major triad, containing the same intervals in the same frequency ratios.  The ratios are certainly the same in equal temperament, and they can also be the same in other temperaments.  They can also be entirely just.  One of two things must be true about this chord progression: either it is devoid of tension and release, or the tension and release cannot be explained by the intervals comprised in each chord.  In the first case, the assumption fails because we have a chord progression that is developed without tension and release.  In the second case, the assumption fails because we have tension and release that is not caused by the vertical intervals in each chord.

I also saw a comment stating "what may sound consonant to one listener may be dissonant to another". I think it is undeniable that any listener on planet earth would find an octave more dissonant than a minor second.

That may be true.  But will they agree on the relative consonance and dissonance of inversions?  Is a minor seventh more or less dissonant than a major second?  Why?  What about a major third and a minor sixth?   What about a perfect fourth and a perfect fifth?  In beginning harmony, I was taught that the fourth in the chord G-C-E-G is dissonant, but the fourth in the chord C-E-G-C is consonant.  How is that possible?
The answer lies in the idea that certain melodic shapes create certain expectations about what is to follow.  This may have little or nothing to do with acoustical tuning.  But regardless, it shows that devising chord progressions that "work" requires taking more into account than simply the degree of consonance and dissonance of each chord in isolation.
As a final example, consider this exercise:  Take a Bach cantata or other four-part piece, or any harmonic piece really, and a random number generator.  For each chord in the piece, generate a random number between -6 and +7.  Transpose the entire chord up or down by that number of half steps.  If this hypothesis about harmonic music were correct, that it is driven by the internal degree of consonance or dissonance in each chord of the progression, then the resulting music should be just as successful as the original piece.
In fact, that would be true of every possible piece that could be derived this way.  That is, instead of a random number generator to generate one piece, use every combination of n values between -6 and +7, where n is the number of chords, to generate 12n pieces.
It should be obvious that a significant proportion of the resulting pieces, aside from the ones where each chord is transposed by the same number of half steps, or most of them are, would in fact be enjoyable to listen to.
Comment: Thank you for clarifying that just intonation ratios are applicable to 12tet. I understand that consonance and dissonance of a chord revolves around the context of a progression. I am seeking the consonance/dissonance intervals so it creates a spectrum of options between consonance and dissonance that i can later adjust to the context of a chord progression. Consonance/dissonance of inversions is an interesting topic because i would assume that the pre-inversion chord would not be much different given its just a frequency doubling of the original interval.
Comment: Unless the case is that, the orderly position of intervals can shift consonance because of two close by interval relationships. Its to say that if we have a chord with C-E-G, the E-G will have a specific consonance but if we have the G-C beside each other, because of the note position vertically, that could shift the consonance/dissonance? I stated at some point recently, that my question was very specific to interval relationships within a chord and not the progression as a whole, which changes the context but it may have been in another post. This was a very interesting read. Thank you!
Answer: It's not always easy to determine the consonance or dissonance of a chord from the properties of the chord's constituent intervals. Based on practice, the fourth in two-part harmony is generally treated as a dissonance. In three-part harmony, the fourth is dissonant against the bass but consonant between upper parts (64 chord vs 63).
Ulehla Ludmilla has a good book which discusses the dissonance level of various chords in different styles.


Show that there does not exist a holomorphic function $h(z)$ such that $\exp(h(z)) = z$ on the punctured plane without using complex integration?

Question: We must show that there does not exist a holomorphic function $h(z)$ on the domain $\mathbb C - \{0 \}$ such that $\exp(h(z)) = z$ on the complex plane. Can we do this without using complex integration?
I know the proof of the fact that there exists no function whose exponential is the identity function $id(z) = z$ on the complex plane which uses complex analysis.
We proceed by assuming such a  holomorphic $h(z)$ exists. This means that $e^{h(z)} = z$. Differentiating, we get $1 = e^{h(z)} h'(z) = z h'(z)$. This means that $1 = z h'(z)$, or  $h'(z) = 1/z$.
Now we compute $\oint h'(z)$ around the countour $c(t) = e^{2 \pi i t}$ in two different ways:

$\oint h'(z) = h(1) - h(1) = 0$, by using FTC and that the countor starts and ends at the same point: $1$.
$\oint h'(z) = \oint 1/z = 2 \pi i$ by the Residue Theorem

Thus, we get $0 = 2 \pi i$ which is absurd.
However, this proof seems to rely on a lot of the machinery of complex integration to get things done. Is there no "simpler" proof? Can we show that to prove this fact, we somehow "need to" invoke facts about complex integrals?
Ideally, I would want an answer that only uses elementary properties of complex numbers, and properties of the complex exponential, and complex differentiation, but not complex integration.
Comment: What would $h(0)$ be?
Comment: You can show that such an $h$ exists if the domain is restricted to $\mathbb{C}$ minus the nonnegative real axis (the various branches of the complex logarithm). Then show that none of the possible candidates for $h$ extend continuously to the positive real axis.
Comment: You can prove it with the fundamental group which is very nice, but needs some basics in loops...
Comment: Another simple way is to show by taking absolute values  that the image of $h$ on any small punctured neighborhood of zero ($0<|z|<r<1$ will do) excludes the half plane $\Re z \ge 1$ say; this means that $h$ cannot have a singularity at zero (both poles and essential singularities have different local behaviour), so $h$ is continuable there to some finite value $a$ giving $e^a=0$ by analytic continuation; contradiction
Comment: I left it implicit that the domain of $h$ ought to be $\mathbb C - \{0 \}$ since this is what one "naturally expects". Edited for clarity
Answer: Suppose such an $h(z)$ exists. Without loss of generality, we may select $h(1) = 0$ (the argument is similar for any other permissible choice of $h(1)$). Then for any $z, w \in \Omega := \Bbb{C} \setminus \{0 \}$, we must have $$e^{h(z)} e^{h(w)} = zw = e^{h(zw)},$$ which immediately implies the identity $h(zw) = h(z) + h(w) + 2\pi i k(z, w)$ for some continuous function $k: \Omega \times \Omega \rightarrow \Bbb{Z}$.
Since $\Omega \times \Omega$ is connected, $k(z, w)$ must be a constant $k$, and plugging in $z = w = 1$, we find $h(1) = 2h(1) + 2\pi i k$, so that in fact $k = -h(1)/2\pi i = 0$ and $h(zw) = h(z) + h(w)$ for all $z, w \in \Omega$.
By induction we get $$h(z_1 ... z_m) = h(z_1) + ... + h(z_m), \text{ for all } z_1, ..., z_k \in \Omega.$$
If we let $z_1 = z_2 = z_3 = -1$, then the above identity shows $h(-1) = 3h(-1)$, which is only possible if $h(-1) = 0$. But $e^0 = 1 \neq -1$, contradiction.
Edited to add: This type of approach often works well for showing that other inverse functions or multivalued functions (e.g. the square root $f(z) = \sqrt{z}$) cannot be extended holomorphically to $\Bbb{C}$ or $\Bbb{C} \setminus \{ 0 \}$. One can play with a functional equation or identity such a function must satisfy, and then derive a contradiction from the function needing to take on two different values at the same point (without having to use path or contour integration).
To show that the square root $f(z) = \sqrt{z}$ cannot be continuously extended to all of $\Bbb{C}$, for instance, one establishes that $f(zw) = \alpha(z, w) f(z)f(w)$, where $\alpha(z, w) \in \{ \pm 1 \}$; uses connectedness of $\Bbb{C}^2$ to establish that $\alpha(z, w)$ is constant for all $(z, w) \in \Bbb{C}^2$ (either $+1$ or $-1$); and then derives a contradiction from the fact that $\alpha(-1, -1)$ must have the opposite sign as $\alpha(+1, +1)$.(E.g. $f(1) = 1$, then $\alpha(1, 1) = 1$ but $\alpha(-1, -1) = -1$.)
Comment: You know, I kind of felt like maybe having to use the topological concept of connectedness was too "high-powered of machinery" since the OP was asking us to use lower level stuff. But, obviously, they can decide for themselves how they feel about it. And I'm doing the same thing you're doing right now, lol. Just killing time till a friend gets here, doodling some math questions....
Comment: I'm quite aware of how "deleting" answers works, lol. Someone deciding to take down their answer, and then rethinking their decision, hardly seems like gripping, popcorn-worthy drama. I really hope people have better things to do with their lives, on a Friday night.....
Comment: Actually, let me add on to my answer a little bit, I wanted to mention a generalization of this approach, and perhaps it will add interest for those super users who can read both of my answers.
Comment: Your answer seems identical to the now-deleted older answer. What happened? (Note: Users with enough reputation points can always see deleted answers by default, and I am sure they will consider this situation quite awkward.)
Comment: I thought that your argument looked perfectly fine and even upvoted your answers, both original and this one, so I was simply curious. And of course I am a poor soul scrounging around this community at this wonderful Friday night, though that hardly sounds like something to be blamed...
Comment: Thanks a lot for the general story. Is there a book which more of this general technique, without needing techniques of path integration? This method seems like it would make proving facts about [monodromy](https://en.wikipedia.org/wiki/Monodromy) of complex functions way nicer!
Answer: Let's answer the question in a more general context: There exists no continuous function $h:\mathbb{C}\setminus\{0\}\rightarrow\mathbb{C}$ such that $\exp \circ h = id\vert_{\mathbb{C}\setminus\{0\}}$. (Simply connected means that I can change every loop continuously into the null loop, i.e. a single point.)
For the proof, we need some concepts about loops and fundamental groups. Explain everything in detail would make this post into a script, so I will just give the ideas. If you draw a loop starting from (end thus ending in) some $z_0\in \mathbb{C}$, then you can continuously deform it into a single point. However, if you consider $\mathbb{C}\setminus\{0\}$, this is not the case anymore. Indeed, if a loop "goes around $0$, then it is impossible to continuously deform it into a point. By saying that two loops are equivalent iff we can continuously deform one into the other, we get an equivalence relation. In the example of $\mathbb{C}\setminus\{0\}$, two loops are equivalent iff they "go around $0$" the exact same number of times (in the same direction, i.e. clockwise or counter-clockwise). More generally, the equivalence classes of loops form a group with respect to the concatenation of loops. If we look at some (connected) open set $U\subseteq\mathbb{C}$ and some $z_0\in U$, then we write $\pi(U;z_0)$ for this group and we call it the fundamental group. This group describes "the holes" in $U$ in some sense. For example, $\pi(\mathbb{C}\setminus\{0\}, z_0) = \mathbb{Z}$, because we count, how many times a loop "goes around $0$" (positive for the counter-clockwise direction). [It is possible to define this notion in a much more general context!] As for any good structural description, we can translate it when we have a suitable transformation between to set $U,V\subseteq\mathbb{C}$. Indeed, if we have a continuous function $f:U\rightarrow V$, we may define $f(\alpha)$ for any loop $\alpha$ in $U$ as the image of the loop under $f$. Since $f$ is continuous, if $\alpha$ and $\beta$ are equivalent, then so are $f(\alpha)$ and $f(\beta)$. That means that we may define the function $\pi_f: \pi(U,z_0)\rightarrow\pi(V, f(z_0))$ through $\pi_f([\alpha]) := [f(\alpha)]$, where $[x]$ denotes the equivalence class of $x$. This is all we need, I hope it was not too confusing.
Suppose now there were such a function $h$. Since it is continuous, we may consider $\pi_h : \pi(\mathbb{C}\setminus\{0\}, z_0) \rightarrow \pi(\mathbb{C}, h(z_0))$. The same goes for $\pi_{\exp} : \pi(\mathbb{C}, h(z_0))\rightarrow \pi(\mathbb{C}\setminus\{0\}, z_0)$ and $\pi_{\exp\circ h} = \pi_{id_{\mathbb{C}\setminus \{0\}}} = id_{\mathbb{Z}} : \pi(\mathbb{C}\setminus\{0\}, z_0)\rightarrow \pi(\mathbb{C}\setminus\{0\}, z_0)$. It is easy to see that $$\pi_{\exp\circ h} = \pi_{\exp}\circ \pi_h$$. But since $\pi(\mathbb{C}, h(z_0)) = \{ 0\}$ (all loops can be continuously deformed to one point), we have $\pi_{\exp} = 0$ and thus
$$
id_{\mathbb{Z}} = \pi_{\exp\circ h} = 0,
$$
which is a contradiction.
You see that the proof is rather short if the basics are known. And it is worth while to take a closer look at fundamental groups. They are amazing objects and I wish I would have learned more about them before deviating to other domains... They initially came from Poincaré if I am not mistaken and they "characterise" pointed topological spaces. This website has some very nice and easy to follow explanations (and visualisations). Unfortunately, it is completely in French, but that is a beautiful language to learn anyway! (I am not French.)
Comment: Thank you, the answer is very nice. I chose to accept the other answer because it uses less machinery than this one. I do agree that the fundamental group picture is very pretty !
Answer: There cannot be a continuous function $h$ on the unit circle $|z|=1$ such that $e^{h(z)}=z$. If there were, then a connectedness argument could be applied to prove that $h(e^{i\theta})=i\theta+2n\pi i$ for all $0 \le \theta < 2\pi$ and for some fixed integer $n$, which would contradict the assumed continuity of $h$ at $z=1$.


Visual Studio: Can't View Files in a Directory in Project

Question: I'm developing an ASP.NET MVC3 project. I copied the Image directory in Content from the file system. It works just fine but I can't open the image directory in Visual Studio. What can I do to resolve this?
Comment: Right click -- Add Existing Item -- choose images?  Is that what you're looking for?
Comment: oh yes, please add an answer so I can accept. thanks
Answer: Sounds like you need to add the images to your project/solution, versus just placing the images in the folder.
To do so, right click on the Images folder in VS Solution Explorer, then select Add Existing Item, and then choose the images to include in the project/solution add click Add.


How does Apache choose which certificate to use?

Question: Currently Apache is hosting several sub domains with host certificates generated with certbot and a http challenge.
Now I want to setup a default virtual ssl host to redirect non-existing subdomains to the main one. For this purpose I will generate a wildcard certificate with DNS challenge.
Since I am not currently able to automate renewal with DNS challenge, I want to use the wildcard certificate only for the default ssl host in Apache.
My question is: When the first negotiation between Apache and the browser takes place, will Apache then first look for at certificate in the configuration matching the requested host, or will Apache serve the wildcard certificate configured in the default ssl host every time?
Answer: Apache lets you specify the SSLCertificateFile directive at the virtual host level. See SSLCertificateFile, which says "Context: server config, virtual host". So whichever virtual host it uses to answer the request - whether the default virtual host, or another one - it will use the certificate you configure with SSLCertificateFile in that virtual host.
I hope that answers your question?
Answer: The Apache documentation contains a detailed section about which VirtualHost is chosen for a request. A quote from the section "How the server selects the proper name-based virtual host":

It is important to recognize that the first step in name-based virtual host resolution is IP-based resolution. Name-based virtual host resolution only chooses the most appropriate name-based virtual host after narrowing down the candidates to the best IP-based match. Using a wildcard (*) for the IP address in all of the VirtualHost directives makes this IP-based mapping irrelevant.
When a request arrives, the server will find the best (most specific) matching <VirtualHost> argument based on the IP address and port used by the request. If there is more than one virtual host containing this best-match address and port combination, Apache will further compare the ServerName and ServerAlias directives to the server name present in the request.
If you omit the ServerName directive from any name-based virtual host, the server will default to a fully qualified domain name (FQDN) derived from the system hostname. This implicitly set server name can lead to counter-intuitive virtual host matching and is discouraged.

You should create a dedicated Default VirtualHost. Every request to a host not listed explicitly in another VirtualHost block will be directed there, so you can choose which certificate you want to use there.
Comment: The documentation states that the SSL negotiation takes place before anything else. No configuration is read apart from the SSL lines. So I was just wondering if Apache uses the same strategy of choosing which virtual host is a match for the SSL certificate, as when choosing virtual host configuration when the SSL negotiation is over. But reading your answer made me think twice about it... It would not make sense if Apache had different strategies for the two scenarios.
Comment: That's not quite correct. During the SSL handshake the server name is already transmitted ([see SNI](https://en.wikipedia.org/wiki/Server_Name_Indication)), without it it would not be possible to run multiple name VirtualHosts on the same IP address. At that point Apache has already to decide which SSL certificate to use, so the decicion has to be at the start of the SSL negotiation, not afterwards.


Malware scanning in the cloud (Azure)

Question: Has anyone had success implementing a mechanism that can scan uploaded files for malware when using Azure?  In this instance, I would be using their Sites and storage options, rather than controlling an entire OS.
In some cases, I know companies have had appliances that sit inline and scan everything. However, those usually require a physical appliance, which cannot be done in the cloud.
Has anyone seen an efficient alternative in Azure?  I am trying to avoid the following recommendation: "Spin up a VM with an Anti Malware/Anti Virus endpoint agent on it, send the file to that system, and then if the file is still there, believe it is safe"
Answer: Unfortunately the building blocks of every cloud service is a VM! That is how Azure et al. make their money.
If you dump a file into Azure, be it on a server, or straight to a blob then it is simply copied, it would cause a lot of additional work for MS if they needed a process for dealing with false positives etc. As well as the perception problem that they are doing any sort of scanning of files as they are uploaded.
The only way you have got of checking is to spin up a VM and have it scan files as they are delivered, or perhaps have it fire up for an hour a day and do a scan.

Malware scanning in the cloud (Azure)


How to show the quotient of dual space and the annihilator of its subspace is equal to dual of the subspace?

Question: Let $W$ be a subspace of a vector space $V$ over a field $F$. Let $i : W \to V $ denote the inclusion map.
Show that $ \pi: V^*\to W^*$given by $\pi(f) = f\circ i$ is a surjective linear map, with kernel equal to $W^0$. Hence show that $W^* = V^*/W^o$.
Comment: Yup @Amitai Yuval
Comment: Related:http://math.stackexchange.com/questions/741056/the-dual-of-subspace-of-a-normed-space-is-a-quotient-of-dual-x-u-perp-con
Answer: Spelled out differently, all you need to observe is that every linear functional on $W$ can be linearly extended to $V$. The statement then follows from the definition.


How can i Get the paramter of URL contains slash

Question: I have this URL :
 dev.local.co/fr/admin/quoteManag/addquote/numberModel/123456/5

when I want to get the parameter numberModel.
On var_dump I get just "123456", not "123456/5"
Comment: It would be useful if you could edit your question to include the code you are currently using to get the URL parameter.
Answer: You can use urlencode
$parameter = urlencode('123456/5'); // 123456%2F5

echo urldecode($_GET['numberModel']); // 123456/5

Or in your router, create a regex that will accept the slash as part of the parameter.
$route = new Zend_Controller_Router_Route_Regex("numberModel/([0-9\/]*)", array("module" => "MODULE", "controller" => "CONTROLLER", "action" => "ACTION"), array(1 => "numberModel"));

Comment: @Tim Fountain :      So i disply the parameter String on URL
123456/5
when i var_dumped i get just
this 12345
so why i am not Get The All String of Paramter thanks also
Answer: Not 100% but if this was me, I would get the url, explode it using /
Get the last 2 from the array, implode them.
But it depends on how you get the url, do you have a rewrite rule?
If so then I would look in that and you need to just sharpen it up slightly.


Access local storage in angular universal

Question: I have my angular universal app running well. But few of the libraries which I use, internally uses localStorage to set and get data. I can neither omit the libraries nor change it. Being said that, is there a workaround where I can use localStorage in server side.
Answer: Try to use
node-localstorage npm module to use localStorage at the nodejs server side.
Comment: const LocalStorage = require('node-localstorage').LocalStorage;
(global as any).localStorage = new LocalStorage('./scratch');


iPhone showing different results for my CSS overlay over image

Question: Visual problem which shows the difference: https://ibb.co/k6dJqyp
Having issues with the overlay over the image, for the life of me I can't figure out why the iPhone has the overlay longer than the image.
I've tried testing it on multiple devices, cannot replicate the issue like on the iPhone. I've tried replicating on the browser dev tool phone resize, no luck there.
EDIT: problem solved, as safwan mentioned below, if you know which element to target, use the CSS safari hack and the change will implement on Safari :)
Answer: Each browser applies CSS in a slightly different way. You can use CSS hacks to target only Safari as mentioned here, but that is quite complex. I suggest you use JavaScript to find out the browser. If you want to know how to exactly find the brower, check this post. But the actual function is below.
<code>function findBrowser() {
    var ua = navigator.userAgent, tem,
    M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
    if(/trident/i.test(M[1])){
        tem =  /\brv[ :]+(\d+)/g.exec(ua) || [];
        return 'IE '+( tem[1] || '');
    }
    if(M[1] === 'Chrome'){
        tem = ua.match(/\b(OPR|Edge?)\/(\d+)/);
        if(tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg ', 'Edge ');
    }
    M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
    if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
    return M.join(' ');
}

if(findBrowser() === 'Safari 13') {
    document.querySelector('img').classList.add("inSafari");
}
</code>
Change 'Safari 13' to the version of Safari which is causing the problem.
Then, in your stylesheet:
<code>.inSafari {
    ...
}
</code>
Comment: BOOM, thank you, used the hack and it worked!, I knew which element i needed to change.
Comment: Oh, that's great to hear. I edited it to use without the hack anyway.
Comment: Does it make a difference if I leave the hack?, also if I change Safari 13 to the problem version, what about other versions?
Comment: No, use the hack if it works. I haven't used it, so I wasn't sure if it would work.
Comment: Ahh, all good, but yes :D! i knew the element which was causing the problem, I just didnt know how to change just safari without causing other issues on other browsers, but yes thank you, problem solved :D


How to store user state in Android in my case

Question: I'm asking this question because I want to be sure which is the best way to store the user "logged in" / "logged out" state in my android application.
Here is what I am doing. In my application I connect to the server, send him username and password and if everything is ok it returns me OK. So now I want to be able to save the user logged in state all over my application because I need to change the content depends on that  if user is logged in or not.
And the other thing is that I need to be able to save the user's login state, so the next time when he start the application he will be automatically logged in.
Any suggestions or ideas which is the best way to do that?
I made a little research over internet and find a few ways to do that :

MyApplication class which extends android.app.Application
SharedPreference
Or maybe a SQLite
Answer: I use static classes or SharedPreference - it'is easy and it's works.
SQLite it not good way (in my opinion)
Answer: your option SharedPreference is the perfect one in this condition as you need to store only boolean and you will access if often in your app to change the content.
Answer: There can be many reasons when your app looses focus, like pressing home button incoming call, etc but no matter what happens your onPause method of current Activity is called so what you have to is-

Override onPause method of every activity
Use SharedPreference to save the state of Application
Answer: The problem with storing the state on the device (using either the SharedPreferences or SQLite) is that the user can manipulate it. So if you simply store "isLoggedIn" in your SQLite-Database, this entry can be manipulated using dpms (for example).
So if you need to store the state, you should use the Application-class (this can be manipulated, too, but it's harder to do so). If the user closes the application, you destroy the state-variable so he needs to do the login when the application is opened the next time.
For usability, you could store username and (if the user wants so) the password.
Also, if you have a web-service that you use to check if the users login-data is correct, why don't you use for example OAuth to authentify the user on the server and deliver the content from it? This would basically make your application a pure "client".
Answer: SharedPreference is the best option to access single value in terms of timing which i observe to be true as compared to sql lite.