text:
Q: Custom Edittext using onDraw and cursor position mismatch? I am making an custom Edittext . Here is the code :-
package com.wysiwyg.main;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.EditText;

public class LineEditText extends EditText {
    private Rect mRect;
    private Paint mPaint;

    // we need this constructor for LayoutInflater
    public LineEditText(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setColor(Color.BLUE); //SET YOUR OWN COLOR HERE
        setMinLines(15);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int height = getHeight();
        int line_height = getLineHeight();

        int count = height / line_height;
        if(getLineCount() > count){
            count = getLineCount();
        }
        Rect r = mRect;
        Paint paint = mPaint;
        int baseline = getLineBounds(0, r);

        for (int i = 0; i < count; i++) {

            canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
            baseline += getLineHeight()+10;//next line
        }

        // Finishes up by calling the parent method
        super.onDraw(canvas);
    }
}

Now this line baseline += getLineHeight()+10;//next line , draws the next line at a specific space above the line. Now the cursor position does not move with respect to the line. If i press enter, then the cursor first comes above the line ,then i press enter, it comes in between the line.
I hope you are getting my meaning.

A: Try this way
public class MyEditText extends EditText {

    public MyEditText(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    public MyEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public MyEditText(Context context) {
        super(context);
        init(context);
    }

    private void init(Context mContext) {
        setLineSpacing(2, 1); // You can set here as your requirement
    }

}


text:
Q: Custom PHP Page within WordPress with $_SESSION I have a separate file , a custom php file that calls API from another system. I put it in a folder under the theme.
Example, under wp-content/themes/myTheme/api
In the API , I have session_start and register a session  $_SESSION['data'] = "abc";
In the file itself the session is there, but once I go to another page within the theme, the session is gone.
In my theme header.php, there is session_start(). I am able to pass session from the files within the theme folder, but under the "api" folder I can't pass the session. Any idea how I should go about?
Thanks in advance.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Viewing applications in WPF with errors I have an application that breaks the image when the screen size changes
Below is the screen
Where can the mistake be? What can cause this situation? I do not even know where to look because it is not a permanent error only once and once is gone
This is how I load items with a line and number per view:
<ItemsControl ItemsSource="{Binding ConnectorsGridsHorizontal, Mode=TwoWay}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

Function drawing 1 element:
public Grid DrawConnector1(Thickness margin, int nr, bool rotate, bool rightSide)
{
    Grid grid = new Grid();
    grid.Margin = margin;

    grid.HorizontalAlignment = HorizontalAlignment.Left;
    grid.Width = S10;
    grid.Height = 128;
    grid.VerticalAlignment = System.Windows.VerticalAlignment.Center;

    Line line = new Line();
    line.X1 = S10HALF;
    line.X2 = S10HALF;
    line.Y1 = 0;
    line.Y2 = 128;
    line.StrokeDashArray = new System.Windows.Media.DoubleCollection() { 4, 2, 1, 2 };

    line.Stroke = System.Windows.Media.Brushes.Green;
    line.StrokeThickness = 4;

    grid.Children.Add(line);

    Grid inGrid = new Grid();
    inGrid.Width = S10;
    inGrid.Height = HF;
    inGrid.Background = System.Windows.Media.Brushes.Black;

    grid.Children.Add(inGrid);

    Border br = new Border();
    br.BorderThickness = new Thickness(0);
    br.CornerRadius = new CornerRadius(10);
    br.Background = System.Windows.Media.Brushes.White;
    br.Margin = new Thickness(-10, -10, -10, -10);
    br.Width = 20;
    br.Height = 20;
    br.VerticalAlignment = rightSide ? VerticalAlignment.Top : VerticalAlignment.Bottom;
    br.RenderSize = new System.Windows.Size(br.ActualWidth + 1, br.ActualHeight + 1);

    if (SelectedConnector + 1 == nr) br.Background = System.Windows.Media.Brushes.Green;
    else br.Background = System.Windows.Media.Brushes.White;

    if (DisableGreenMark) br.Background = System.Windows.Media.Brushes.White;

    TextBlock txtBlock = new TextBlock();
    txtBlock.FontSize = 16;
    txtBlock.Text = nr.ToString();
    txtBlock.Foreground = new SolidColorBrush(Colors.Black);
    txtBlock.VerticalAlignment = VerticalAlignment.Center;
    txtBlock.HorizontalAlignment = HorizontalAlignment.Center;

    br.Child = txtBlock;

    grid.Children.Add(br);

    Binding b = new Binding("S60_20");
    b.Mode = BindingMode.Default;
    grid.SetBinding(Canvas.TopProperty, b);

    return grid;
}

GIF:

I'm also using SnapsToDevicePixels="true"

A: To start with, try doing this:
br.HorizontalAlignment = HorizontalAlignment.Stretch;
br.Margin = new Thickness(0, 0, 0, 0);

*

*Do not use margin with a negative value

*Stretch will provide you with an element extension

Side cut is probably caused by too narrow a strip for the element:
You have:
grid.Width = S10;

line.X1 = S10HALF;
line.X2 = S10HALF;

This indicates that you have the width set to probably 10
and Here you have set to 20
br.Width = 20;
br.Height = 20;

I also suggest changing here:
grid.Width = S10 * 2;

line.X1 = S10HALF * 2;
line.X2 = S10HALF * 2;


text:
Q: An invariant subspace of $\mathcal{A}$ must be the kernel of a commuting linear operator $\mathcal{B}$
Suppose $\mathcal{A}$ is a linear operator on some vector space $V$, and suppose $U$ is a $\mathcal{A}$-invariant subspace of $V$. Does there necessarily exist a corresponding linear operator $\mathcal{B}$ such that $\mathcal{A}\mathcal{B}=\mathcal{B}\mathcal{A}$ and $U$ is the kernel of $\mathcal{B}$ ?

My thought
First I wanted to find a complementary $\mathcal{A}$-invariant subspace $U'$ such that $V= U \oplus U'$. If this can be done it's easy to solve this problem.
But I found this idea infeasible, and from this post I realized it is a property when the minimal polynomial of $\mathcal{A}$ is a product of distinct irreducibles.
Then I wanted to proceed by assuming that $\mathcal{A}$ has a matrix representation $A=\begin{pmatrix}
A_1 & A_2 \\
0 & A_3
\end{pmatrix}$ under the basis $(\alpha_1,\alpha_2,\dots,\alpha_n)$ where $(\alpha_1,\alpha_2,\dots,\alpha_r)$ is the basis of $U$.
Write $B=\begin{pmatrix}
0 & B_1 \\
0 & B_2
\end{pmatrix}$.
From $AB=BA$ we get
\begin{alignat}{2}
A_3B_2 & = B_2A_3 \\
A_2B_2 & = B_1A_3-A_1B_1 \\
\end{alignat}
I've known that (supposing we are working on $\mathbb{C}$) $$AX=XB$$ only has zero solution iff $A$ and $B$ have no common eigenvalue.
Supposing we are working on $\mathbb{C}$, then by root subspace decomposition, we can assume that $A_3$ and $A_1$ have common eigenvalues, otherwise we can write $U$ as a union of some root subspaces. (Write $f(\lambda)=\prod_{i=1}^s (\lambda - \lambda_i)^{k_i}$ and $R_i = \ker (\mathcal{A}-\lambda_i\mathcal{I})^{k_i}$. Note that the dimension of the root subspace is its algebraic multiplicity, and hence if $U\cap R_i \ne R_i$, $A_3$ must has an eigenvalue $\lambda_i$. )
Thus we can put $B_2 = 0$ and $B_1 $ being the non-zero solution of $A_1X=XA_3$.
But how do I guarantee that $B_2$ is of full rank? Otherwise it may still not satisfy that the kernel of $\mathcal{B}$ is $U$.
Any hints? Thanks in advance!


text:
Q: How to select and transfer specific string values into new column in SQL? I have a table of items that can be arranged into groups. The table contains an attribute column with string values, as an example I chose color. For some items, the color column is empty.

ItemID
Group
Color

001
A
'blue'

002
A
'blue'

003
A
'blue'

004
A
'blue'

005
A

101
B
'red'

102
B
'red'

103
B

104
B

105
B
'green'

From this table I want to select only the items that do not have a color assigned yet and display a proposed color in a new column. The proposed color should be taken from the item with the highest ID value within each group.
The desired output should look like this:

ItemID
Group
Proposed Color

005
A
'blue'

103
B
'green'

104
B
'green'

I have no idea how to select specific values from the color column based on values from another column (in this case ItemID) and assign them to a different row within my table.
Any help (also keywords describing the concept associated with my problem...) would be greatly appreciated!
(edit) This is what I've tried so far:
WITH temp_id AS (
SELECT max(ItemID), GroupName
FROM myTable
WHERE Color IS NOT NULL
GROUP BY GroupName
)
SELECT myTable.*, temp_id.*
FROM myTable
JOIN temp_id
ON temp_id.groupName = myTable.groupName;

But the output is missing the color column and I wasn't able to add a condition WHERE Color IS NOT NULL to my outer selection.

A: You have to join again with myTable in order to get the Color of the MaxID you calculated in the temp_id table:
WITH temp_id AS (
SELECT max(ItemID) AS MaxId, GroupName
FROM myTable
WHERE Color IS NOT NULL
GROUP BY GroupName
)
SELECT myTable.*, T2.Color
FROM myTable
JOIN temp_id
ON temp_id.groupName = myTable.groupName
JOIN myTable T2
ON T2.ItemID = temp_id.MaxID;

Fiddle here.

A: This could work as well:
WITH test_data AS
(
  SELECT '001' AS "item_id", 'A' AS "group", 'blue' AS "color" FROM DUAL UNION ALL
  SELECT '002', 'A', 'blue'  FROM DUAL UNION ALL
  SELECT '003', 'A', 'blue'  FROM DUAL UNION ALL
  SELECT '004', 'A', 'blue'  FROM DUAL UNION ALL
  SELECT '005', 'A', NULL    FROM DUAL UNION ALL
  SELECT '101', 'B', 'red'   FROM DUAL UNION ALL
  SELECT '102', 'B', 'red'   FROM DUAL UNION ALL
  SELECT '103', 'B', NULL    FROM DUAL UNION ALL
  SELECT '104', 'B', NULL    FROM DUAL UNION ALL
  SELECT '105', 'B', 'green' FROM DUAL
)
SELECT items."item_id", items."group", colors."proposed color"
  FROM (SELECT td."group", MIN(td."color") AS "proposed color"
          FROM test_data td
         GROUP BY td."group") colors
         INNER JOIN (SELECT td."item_id", td."group"
                       FROM test_data td
                      WHERE td."color" IS NULL) items
            ON items."group" = colors."group"
 ORDER BY items."item_id";

A: As you're close, I'll give you the answer, feel free to ask if you don't understand :
SQL Fiddle
Query 1:
-- full query
SELECT mt.itemID, mt.Group, tColor.Color as proposedColor
FROM myTable as mt
LEFT JOIN (
  SELECT tMax.Group, tC.Color
  FROM (
    SELECT max(t.ItemID) ItemID, t.Group
    FROM myTable as t
    WHERE t.Color IS NOT NULL
    GROUP BY t.Group
    ) tMax
  LEFT JOIN myTable tC
    ON tC.ItemID = tMax.ItemID
  ) tColor
  ON tColor.Group = mt.Group
WHERE mt.Color IS NULL

Results:
| itemID | Group | proposedColor |
|--------|-------|---------------|
|      5 |     A |          blue |
|    103 |     B |         green |
|    104 |     B |         green |

Query 2:
-- details :
-- 1) the get max id per group

SELECT max(t.ItemID) ItemID, t.Group
FROM myTable as t
WHERE t.Color IS NOT NULL
GROUP BY t.Group

Results:
| ItemID | Group |
|--------|-------|
|      4 |     A |
|    105 |     B |

Query 3:
-- 2) the color per group
SELECT tMax.Group, tC.Color
  FROM (
    SELECT max(t.ItemID) ItemID, t.Group
    FROM myTable as t
    WHERE t.Color IS NOT NULL
    GROUP BY t.Group
    ) tMax
  LEFT JOIN myTable tC
    ON tC.ItemID = tMax.ItemID

Results:
| Group | Color |
|-------|-------|
|     A |  blue |
|     B | green |

Query 4:
-- 3) the row that need a proposed color
SELECT mt.itemID, mt.Group, null as proposedColor
FROM myTable as mt
-- LEFT JOIN...
WHERE mt.Color IS NULL

Results:
| itemID | Group | proposedColor |
|--------|-------|---------------|
|      5 |     A |        (null) |
|    103 |     B |        (null) |
|    104 |     B |        (null) |

A: You can use a MAX window function to retrieve the value of "Color" with respect to each ItemID, then get the rows that had "Color" assigned null:
SELECT ItemID,
       Group_,
       MaxColor AS Color
FROM (SELECT *,
             MAX(Color) OVER(
                 PARTITION BY Group_
                 ORDER     BY CAST(ItemID AS UNSIGNED)) AS MaxColor
      FROM tab) cte
WHERE Color IS NULL

Check the demo here.
Note: If you don't care about selecting only those specific rows with NULL values, you can just use the window function as follows.
SELECT ItemID,
       Group,
       COALESCE(Color, MAX(Color) OVER(
                           PARTITION BY Group
                           ORDER     BY CAST(ItemID AS UNSIGNED))) AS Color
FROM tab

The COALESCE function will give priority to the Color field, and when it is null, it will catch the MAX window function output.


text:
Q: How can I create an EFI partition on my USB drive? I was trying to install GRUB onto an USB drive. I want to create a multi-boot USB disk, but I am getting an EFI directory not found error. How can I successfully create an EFI partition on my USB flash drive?

A: You can use GParted for this task (create an EFI partition) ... to install it open a terminal and execute :
sudo apt install gparted

Open GParted from the Dash, select the USB drive, create a new gpt partition table and then create some new partitions. Here is a presentation I made how to do it -> How to prepare a disk with GParted

A: Creating an EFI System Partition (ESP) can be done in several ways, but is only the start of what you need to do. An ESP is a partition with a GPT type code of C12A7328-F81F-11D2-BA4B-00A0C93EC93B (or, on an MBR disk, a type code of 0xEF) and that uses the FAT32 filesystem (although FAT16 or even FAT12 can generally be used). In Linux, libparted-based tools, such as GParted and parted, identify the ESP on a GPT disk by the presence of a "boot flag," so you must set that flag on the ESP -- but this works only on GPT disks. (I think that recent versions of libparted use the "esp flag" as a synonym for "boot flag," so you could set that instead. This might work on MBR disks, too, but I'm not positive of that.) In GPT fdisk (gdisk, sgdisk, and cgdisk), it's identified by a partition type of EF00.
If you create an ESP with GParted, it can create the FAT filesystem at the same time you create the partition. If you use parted or GPT fdisk, you'll need to do so by running mkdosfs or some other tool.
Once the partition is created, you must copy a boot loader to the file EFI/BOOT/bootx64.efi (assuming booting on x86-64 systems with 64-bit EFIs). You mention GRUB, and that can be tricky because GRUB relies on configuration files with locations embedded in the GRUB binary; but the standard Ubuntu GRUB looks to your hard disk for its configuration file. There are GRUB installation scripts that can help set things up automatically, but I'm not very familiar with them. You might want to consider using my rEFInd boot manager instead. It will automatically scan for boot loaders on startup, so it most likely will require very little configuration, and its configuration file resides in the same directory as the rEFInd binary.
One more caveat: If your USB drive is meant to be bootable on computers with Secure Boot active, you'll need to copy shimx64.efi, not grubx64.efi or refind_x64.efi, to the USB drive's EFI/BOOT/bootx64.efi file; then copy the follow-on boot loader as grubx64.efi. rEFInd might not be the best choice in this case, either, since using it would necessitate manually adding rEFInd's keys to every computer you use with Secure Boot active. (OTOH, if you just want to boot on one computer, that might be an acceptable cost.)


text:
Q: creating several smoothgallery objects on one page I have a website and I want to have several slide galleries on one page.
I am using javascript and smoothgallery to create the galleries. But I can't make it to work with several objects of galleries. It only shows one gallery and ignores the other one.
This is my javascript code.

And this is my HTML code.

How can I make it work and actually see myGallery and myGallery1 next to each other?
Thanks!


text:
Q: Scroll programmatically collection view I have a horizontally collection view .
What I want is to add a button, and when is pressed to auto scroll to the next cells. How to do this?
I was trying this method but it's not working:
- (IBAction)scrollCollection:(id)sender {

    NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];

    NSArray *indexPaths = [self.notesCollection indexPathsForSelectedItems];
    if ( indexPaths.count > 0 )
    {
        NSIndexPath *oldIndexPath = indexPaths[0];
        NSInteger oldRow = oldIndexPath.row;
        newIndexPath = [NSIndexPath indexPathForRow:oldRow + 1 inSection:oldIndexPath.section];
    }
}

and this:
- (IBAction)scrollCollection:(id)sender {

    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)[self.notesCollection collectionViewLayout];
    [self.notesCollection setPagingEnabled:YES];
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
     self.notesCollection.contentOffset = self.scrollingPoint;
    // Here you have to respond to user interactions or else the scrolling will not stop until it reaches the endPoint.
    if (CGPointEqualToPoint(self.scrollingPoint, self.endPoint)) {
        [self.scrollingTimer invalidate];
    }
    // Going one pixel to the right.
    self.scrollingPoint = CGPointMake(self.scrollingPoint.x, self.scrollingPoint.y+1);
}

A: You can try this one
@property (nonatomic, assign) CGPoint scrollingPoint, endPoint;
@property (nonatomic, strong) NSTimer *scrollingTimer;
@synthesize scrollingPoint, endPoint;
@synthesize scrollingTimer;

- (void)scrollSlowly {
    // Set the point where the scrolling stops.
    self.endPoint = CGPointMake(0, 300);
    // Assuming that you are starting at {0, 0} and scrolling along the x-axis.
    self.scrollingPoint = CGPointMake(0, 0);
    // Change the timer interval for speed regulation.
    self.scrollingTimer = [NSTimer scheduledTimerWithTimeInterval:0.015 target:self selector:@selector(scrollSlowlyToPoint) userInfo:nil repeats:YES];
}

- (void)scrollSlowlyToPoint {
    self.collectionView.contentOffset = self.scrollingPoint;
    // Here you have to respond to user interactions or else the scrolling will not stop until it reaches the endPoint.
    if (CGPointEqualToPoint(self.scrollingPoint, self.endPoint)) {
        [self.scrollingTimer invalidate];
    }
    // Going one pixel to the right.
    self.scrollingPoint = CGPointMake(self.scrollingPoint.x, self.scrollingPoint.y+1);
}

Or you can use this code too.
NSInteger section = [self numberOfSectionsInCollectionView:collectionView] - 1;
NSInteger item = [self collectionView:collectionView numberOfItemsInSection:section] - 1;
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];
[collectionView scrollToItemAtIndexPath:lastIndexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];


text:
Q: Custom attribute is not showing in one-step-checkout address list Show custom attribute "province".Value is saving in "customer_address", "quote_address" and "sales_order_address" tables.
setup > Upgrade.php
    protected function _addAttributes($setup)
    {
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

    $customerSetup->addAttribute('customer_address', 'province', [
        'label' => 'Province',
        'input' => 'text',
        'type' => 'varchar',
        'source' => '',
        'required' => false,
        'position' => 333,
        'visible' => true,
        'system' => false,
        'is_used_in_grid' => false,
        'is_visible_in_grid' => false,
        'is_filterable_in_grid' => false,
        'is_searchable_in_grid' => false,
        'backend' => '',
        'comment' => 'Province'
    ]);

    $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'province')
        ->addData(['used_in_forms' => [
            'customer_register_address',
            'customer_account_create',
            'adminhtml_customer_address',
            'customer_account_edit',
            'adminhtml_customer',
            'adminhtml_checkout',
            'checkout_register',
        ]]);
    $attribute->save();

    $setup->getConnection()->addColumn(
        $setup->getTable('quote_address'),
        'province',
        [
            'type' => 'text',
            'length' => 255,
            'comment' => 'Province'
        ]
    );

    $setup->getConnection()->addColumn(
        $setup->getTable('sales_order_address'),
        'province',
        [
            'type' => 'text',
            'length' => 255,
            'comment' => 'Province'
        ]
    );

    $setup->endSetup();
}

fieldset.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
<scope id="global">
    <fieldset id="customer_address">
        <field name="province">
           <aspect name="to_quote_address" />
        </field>
    </fieldset>
    <fieldset id="sales_convert_quote_address">
        <field name="extension_attributes">
            <aspect name="to_customer_address" />
            <aspect name="to_order_address" />
        </field>
    </fieldset>
    <fieldset id="sales_convert_order_address">
        <field name="extension_attributes">
             <aspect name="to_quote_address" />
        </field>
    </fieldset>
</scope>

Observer created to add attribute in collection:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

<event name="sales_quote_address_save_after">
  <observer name="iversa_customaddress_observer_address" instance="Iversa\CustomAddress\Observer\Address" />
</event>
<event name="sales_order_address_save_after">
    <observer name="iversa_customaddress_observer_address" instance="Iversa\CustomAddress\Observer\Order\Address" shared="false" />
</event>
<event name="sales_quote_address_collection_load_before">
    <observer name="iversa_customaddress_observer_addresscollectionload" instance="Iversa\CustomAddress\Observer\AddressCollectionLoad" shared="false" />
</event>
<event name="sales_order_address_collection_load_before">
    <observer name="iversa_customaddress_observer_order_addresscollectionload" instance="Iversa\CustomAddress\Observer\Order\AddressCollectionLoad" shared="false" />
</event>
</config>

I have refer https://web4pro.net/blog-news/magento-2-add-custom-attribute-customers-address/ and http://devdocs.magento.com/guides/v2.1/howdoi/checkout/checkout_new_field.html to showing the value in magento2 onstepcheckout address. Also refer screenshot for the same.


text:
Q: How to find out the html code for a currency? The html code for USD '$' is $. How could I find the html codes for other currencies? Thanks a lot.

A: here are some:
Test for Unicode support in Web browsers Currency Symbols
http://www.alanwood.net/unicode/currency_symbols.html
HTML - Special Entity Codes
http://tlt.its.psu.edu/suggestions/international/web/codehtml.html
Currency Internationalization (i18n), Multiple Currencies and Foreign Exchange (FX)
http://www.xencraft.com/resources/multi-currency.html
Special ASCII HTML Character Codes
http://www.yellowpipe.com/yis/tools/ASCII-HTML-Characters/index.php

A: This can be helpful: http://webdesign.about.com/od/localization/l/blhtmlcodes-cur.htm

A: Look up their hexadecimal representation in a character map (charmap both on Windows and in Gnome)
Then &#codepoint; should do the trick, e.g.  for the digit 1.

A: You can do it with Intl.NumberFormat native api. See also
new Intl.NumberFormat([locales[, options]]);

function testCurrencyDisplay(locale, currency, display) {
  let formatted = new Intl.NumberFormat(locale, {
    style: 'currency',
    currencyDisplay: display,
    currency: currency
  }).format(65421.45);
  return formatted;
}

function testAndPrint(locale, currency, display) {
  console.log(`${locale} ${currency} ${display}: \t` + testCurrencyDisplay(locale, currency, display));
}

let locales = ['en-US', 'en-CA', 'es-MX', 'zh-CN', 'zh-HK', 'ja-JP', 'de-DE'];
let currencies = ['USD', 'CAD', 'MXN', 'CNY', 'HKD', 'JPY', 'EUR'];

locales.forEach((locale) => {
  currencies.forEach((currency) => {
    testAndPrint(locale, currency, 'symbol');
    testAndPrint(locale, currency, 'code');
  });
});


text:
Q: adding url link in a function This is probably an easy fix, but I am new to this.  I have some code from a previous developer and I have been asked to edit the text for the email that gets sent out.  I have tried using a regular href tag but that doesnt work.  Is there a specific way to add a URL in the example below?  It is the Ready to get started line.  The click should be hyperlinked.  Thanks!!
function send_info_kit(){
        if($_POST):
        $to = mysql_real_escape_string($_POST['email_info']);
        $q = "INSERT INTO rog_info_requesters(`email`) VALUES('{$to}')";
        $r = mysql_query($q) or die(mysql_error());
        print $to;

        $from ='support@reachingourgoal.org';
        $name = 'Reaching Our Goal';
        $subject='Info kit you requested';
        $message=nl2br('Information on America's best fundraising program for sports teams and
        school groups is attached.

Finally, a modern process that generates thousands of dollars in profit and
takes just minutes to launch.

A few reasons why www.rechingourgoal.org is the right choice:

- Takes minutes
- No selling
- 80% Profits
- Online tracking
- We do the work

Ready to get started now?  http://www.reachingourgoal.org"Click!

Text ROG to 9192835123. Get clued in on amazing results and success tips.

We are helping people like you do amazing things every day.

Reaching Our Goal
www.ReachingOurGoal.org
');
        $cc='';
        $bcc='junk@reachingourgoal.org,jon@mysportsdreams.com';
        //$attach='http://www.reachingourgoal.org/assets/images/ReachingOurGoalInfoKit.pdf';
        $file = FCPATH .'/assets/images/ROGFreeInfo.pdf';

        if(file_exists($file)):
        {
            echo "File exists. Path ok: " . $file;
        }
        else:
        {
            echo "Cannot find file: " . $file;
        }
        endif;
        $this->member->send_info($to,$from,$name ,$subject,$message,$cc,$bcc,$file);
        endif;
    }

A:  $message=nl2br('Information on America's best fundraising program for sports teams and
        school groups is attached.

Finally, a modern process that generates thousands of dollars in profit and
takes just minutes to launch.

A few reasons why www.rechingourgoal.org is the right choice:

- Takes minutes
- No selling
- 80% Profits
- Online tracking
- We do the work

Ready to get started now?  Click!

Text ROG to 9192835123. Get clued in on amazing results and success tips.

We are helping people like you do amazing things every day.

Reaching Our Goal
www.ReachingOurGoal.org
');

A: you can do like following,
$message = 'string !click'

A: Replacing
http://www.reachingourgoal.org"Click!

with
Click!

does the job.


text:
Q: How to make an image roll I want to make a next-prev type web comic image gallery like that of xkcd or smbc
The following is the first idea to pop into my head.
HTML:

Oscars 2015

 <button id="prev" onclick="prev(); return false;" disabled>PREVIOUS</button>
 <button id="next" onclick="next(); return false;">NEXT</button>

(#) title

JavaScript:
var img = [
 ["http://i.imgur.com/B1YclC5.jpg", "Birdman or (The Unexpected Virtue of Ignorance) won Best Picture."],
 ["http://i.imgur.com/XjAdinX.jpg", "Eddie Redmayne won Best Actor in a Leading Role for his role in The Theory of Everything."],
 ["http://i.imgur.com/kCj3uvC.jpg", "Julianne Moore won Best Actress in a Leading Role for her role in Still Alice."],
 ["http://i.imgur.com/OJq9hq1.jpg", "J K Simmons won Best Actor in a Supporting Role for his role in Whiplash."],
 ["http://i.imgur.com/qZ4XnIJ.jpg", "Patricia Arguette won Best Actress in a Supporting Role for her role in Boyhood."],
 ["http://i.imgur.com/QTGeTJ6.jpg?1","Big Hero 6 won Best Animated Feature Film."]
];

var i = 0;

function setComic() {
    console.log(img[i]);
    document.getElementById("comic").src = img[i][0];
    document.getElementById("num").textContent = i+1;
    document.getElementById("title").textContent = img[i][1];
}

setComic();

function prev() {
    i--;
    if (i <= 0) document.getElementById("prev").setAttribute('disabled', true);
    else document.getElementById("next").disabled = false;
    setComic();
    console.log(i);
}

function next() {
    i++;
    if (i >= img.length - 1) document.getElementById("next").disabled = true;
    else document.getElementById("prev").disabled = false;
    setComic();
    console.log(i);
}

See it in action here!
I wanted to put the buttons both above and below the picture. So, I did and I replaced the next/prev id with classes and used the document.getElementsByClass() thing but it isn't working as I imagined. (code here). And that's just the tip of the iceberg.
My questions are as follows:

*

*How can I make my code more efficient and effective?

*How can I make loading of images better for slow connections?

*Any good advice for making the thing I want to make; resources, tips, etc. etc.

A: You could make use of css for this, and keep your html/jquery to a minimum.
Notice how I've kept the jquery simple, and extracted the src attribute from the img tag down the left hand side, and then used this as my background for my .big image? That way, I'm keeping requests to a minimum by using the image already there

$('.sidepanel img').click(function() {
  var val = $(this).attr("src");
  $('.gallery .big').css("background", "url(" + val + ")").css("background-size", "100% 100%");
});
.sidepanel {
  width: 100px;
  height: 400px;
  display: inline-block;
}
.sidepanel img {
  height: 100px;
  width: 100px;
}
.gallery .big {
  height: 400px;
  width: 400px;
  background: lightgray;
  background-size: 100% 100%;
  display: inline-block;
}

A: Here's an approach. I've added it, rather than simply let the question fall-through to code-review, since it failed to enable/disable the buttons correctly - you may see my comment above for more info.
<!doctype html>

Oscars 2015

    <button class="prevBtn" disabled>PREVIOUS</button>
    <button class="nextBtn">NEXT</button>

(#) title

    <button class="prevBtn" disabled>PREVIOUS</button>
    <button class="nextBtn">NEXT</button>

A: There's no reason for each image to have its own array, for example, you can just use the split(', ') feature.
Also, I added a 'change image' function that receives parameters so you end up using less code.
var images = [
    'http://i.imgur.com/B1YclC5.jpg, description0, alt0',
    'http://i.imgur.com/XjAdinX.jpg, description1, alt1',
    'http://i.imgur.com/kCj3uvC.jpg, description2, alt2',
    'http://i.imgur.com/OJq9hq1.jpg, description3, alt3'],
    max = parseInt(images.length - 1),
    curr = 0;

function display(a, b, c) {
    img = document.getElementById('myImage');
    img.src = a;
    img.setAttribute('alt', b);
    document.getElementById('desc').innerHTML = c;
}

function next() {
    if (curr < max) {
        curr += 1;
        arr = images[curr].split(', ');
        path = arr[0];
        desc = arr[2];
        alt = arr[1];
        display(path, desc, alt);
    }
}

function prev() {
    if (curr > 0) {
        curr -= 1;
        arr = images[curr].split(', ');
        path = arr[0];
        desc = arr[2];
        alt = arr[1];
        display(path, desc, alt);
    }
}

http://jsfiddle.net/scott88/p4utrd7v/


text:
Q: Is there a javascript library can help me to operate textarea?
Possible Duplicate:
how can i get cursor position in a textarea?

I want some basic but common operations on textarea with javascript, such as

*

*get the cursor position

*set the cursor position

*insert some text to the cursor position

*select all text in textarea

*select a range of text

*insert some text to the cursor position, and select it immediately.

I hope it working cross-browers.
Is there such javascript library?

A: There's a jQuery plug-in I've written that does all of this. There's a standalone version too but it needs a little bit of tidying. If you'd prefer no jQuery then it would give me a reason to sort it out and release it.


text:
Q: 'npm ci' command is not working as expected I have installed a library with version 1.0.0 and then I have modified package.json file with version 1.0.3 and then I run "npm ci" and expecting it should not update the package as it should refer package-lock.json file. But its updated the package to the latest version 1.4.4 in the node_modules.
Why it's happening like this?


text:
Q: Is there a way to process the linux source tree using the config file I am wondering if there is a way to use my .config file for building the Linux kernel and create another source tree with only the code which will actually be used in the build. For instance, if I choose not to include a certain driver, the code for that driver will be left out and all #ifdef CONFIG_<driver> sections will be removed from the resulting code.
I would like to be able to run the C preprocessor on the entire source tree for the kernel without running any of the actual compilation steps so that I can examine the full codebase of the kernel running on my system without any of the extra code included in the Linux project which will be unused when I compile my kernel.
I was wondering if there was any specific tool or step of make commands that would allow me to run a program like unifdef on the entire source tree using what is in my .config file.
Any help would be appreciated, thank you!


text:
Q: Return value is not shown I want output to be shown as "10" but below code outputs "System.Func'1[System.Int32]"
Doesn't function return "10" ? Why is this not displayed?
using System;

namespace ConsoleApplication
{
    class Program
    {
        public int Get10()
        {
            return 10;
        }

        static void Main(string[] args)
        {
            var ten=new Func<int>(new Program().Get10);
            Console.WriteLine(ten);
        }
    }
}

A: Try
Console.WriteLine(ten()):

You are printing the string representation of the Func object.
But you have to invoke it using ()

A: You are encapsulating the method when you declared it as Func, when you call ten, it is not yet invoked.
In order to execute it, you must use .Invoke()
Console.WriteLine(ten.Invoke());
Or use delegate instance
Console.WriteLine(ten());
https://dotnetfiddle.net/d2mPPz

A: Ten is a Func, so if you want to see "10", you need to invoke it like ten.Invoke()


text:
Q: android navigation components passing data between fragment directions Here is my navigation file
<navigation
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/navigation"
    app:startDestination="@id/fragmentA">

    <fragment
        android:id="@+id/fragmentA"
        android:name="com.example.fragmentdatapassings.FragmentA"
        android:label="Fragment A">
        <action
            android:id="@+id/action_fragmentA_to_fragnentB"
            app:destination="@+id/fragmentB" />
        <argument
        android:name="x"
        app:argType="integer" />
    </fragment>

    <fragment
        android:id="@+id/fragmentB"
        android:name="com.example.fragmentdatapassings.FragmentB"
        android:label="FragmentB">
    </fragment>

</navigation>

Here is the code for fragment directions data passing.
val x : Int = 10
val action = FragmentADirections.actionFragmentAToFragnentB(x)
Navigation.findNavController(requireView()).navigate(action)

the above 2nd line shows error

Too many arguments for public open fun

When I hover the mouse over the error, it shows add parameter x, I do click it and it does
add the parameter x in FragmentADirections. But after building the app again it shows error
again.

A: <argument> should be in fragment you want to receive not from which you are sending
If you want to pass data from fragment A to B
  <fragment
        android:id="@+id/fragmentB"
        android:name="com.example.fragmentdatapassings.FragmentB"
        android:label="FragmentB">
        <argument
        android:name="x"
        app:argType="integer" />
    </fragment>

and delete argument from fragment A and it should be fine as it is


text:
Q: Installing Ubuntu server alongside Ubuntu Desktop 14.04.1 LTS My current configuration:

*

*Dual boot with GRUB for Win 7 and Ubuntu Desktop 14.04.1 LTS. Running fine with options to got Win 7 or Ubuntu.

*Installed Ubuntu Studio after this. Running fine with option to go to desktop / Studio after selecting Ubuntu after Step 1 above.

*I now want to install Ubuntu Server on the same machine alongside the existing set up.

*Would it be possible to get an option on booting up to select from Win 7/ Ubuntu desktop / Ubuntu Server? Alternatively is it possible to get option to choose from Ubuntu Desktop / Ubuntu Server /Ubuntu Studio ?
Please help me out with this task.
Regards and best wishes.
Sunil

A: Once you are dualbooting adding another install should be straightforward. Ubuntu server shouldn't be any different in terms of installing to the versions you have already installed.
All entries should show up on the grub menu.

A: Unless you have some compelling reason to have a seperate server install, why not just install the required packages in your desktop/ubuntu studio install? Why not just keep your ubuntu studio install (for the lower latency kernel and jack setup),delete your ubuntu install, then just install the packages you use in the studio install?


text:
Q: Aligning Images in a grid style I am trying to align my images in a grid like format within LaTeX and have done so like this:
\documentclass[a4paper,11pt,fleqn,titlepage]{article}
\usepackage[margin=2.5cm]{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ...
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{ulem}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{epstopdf}
\usepackage{longtable}
\usepackage{color}
\usepackage{showframe}
\usepackage{subfigure}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\begin{document}

\newpage

\begin{figure}[!ht]
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-4.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-5.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-6.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-7.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-8.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-9.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-10.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-11.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-12.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-13.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-14.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-15.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-16.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-17.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-18.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-19.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-20.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-21.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-22.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-23.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-24.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-25.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-26.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-27.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-28.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-29.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-30.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-31.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-32.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-33.eps}}}
\end{figure}

\newpage
\end{document}

This works fine for me for the first two lines of images (I have five on each line) however when it gets to the third line of images the vertical space between the images increases and I don't know why.
Is there a way to make my images align so that:

*

*The entire figure is top aligned vertically and centrally aligned horizontally to a new page.

*The subfigures have five on each line.

*The subfigures are aligned centrally horizontally within the figure.

*The subfigures are aligned by the top vertically on each line.

*The spacing between all subfigures is equal both between them on the same line and from one line to the next.
If you imaging a piece of paper with a grid draw in the centre and an image in the centre of each square in the grid, that's what I want. I get the feeling I am either really close or just doing something horrendously wrong! Any help would be greatly appreciated.
Note: I have only put the boxes in to see where the images begin and end, these shall be removed.

A: You want a blank line before each \vspace so that the space comes at that point, currently they are all set as a single paragraph \vspace within a paragraph has a defined (but usually unwanted) behaviour
Also unless you are having individual captions you don't need subfigure you could just use \includegraphics directly.

Please when making an example, try to make it minimal by removing unused packages and not relying on unavailable images, something like:
\documentclass[a4paper,11pt,fleqn,titlepage]{article}
\usepackage[margin=2.5cm]{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ...
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{subfigure}

\begin{document}

\newpage

\begin{figure}[!ht]
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\end{figure}

\newpage
\end{document}


text:
Q: nextjs webpack autogenerate definition.ts files from css module output is there a way to configure nextjs to access to every css module output and auto generate a file definition?
the idea is to watch css/scss and jsx files changes (based on some tag in the file), to update the relative autogenerated files.
the typed signature will be a transformation of the css module out put.
something like this.
// a simple style.module.scss
.root {
 color: red;
 &--border-2x: {
   border: solid 2px red;
 }
}

.root__header {
  font-size: 24px;
}

// autogenerated autogenerated-style.module.ts
import style from "./style.module.scss";

// a simple example of mapping
// style = { root: string, root--border-2x: string, root__header: string }
export interface MyType {
  Root: { "$root-border-2x": string };
  RootHeader: {}
}

export const myMappedStyle: MyType = mapStyle(style);


text:
Q: Control without a form in VB.NET I would like to make an application where there is no form, only controls, this way theuser can see what they are doing on top of their work. How could I for instance put a textbox on the screen, just like form1, but without it being a parent of form1, almost as if it was form1. Basically form1 is hidden.
Thanks

A: Your controls have to be part of a form.
You can still do this by setting the form's opacity:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.opacity.aspx

A: Hide form1. Either make it a borderless form the same size as your control, or make it a broderless form and look into the TransparencyKey attribute on it.


text:
Q: Select attribute via XPath only if child element does not exist? I have a sample XML fragment that is like below
<asdiOutput xmlns="http://tfm.faa.gov/tfms/TFMS_XIS" xmlns:nxce="http://tfm.faa.gov/tfms/NasXCoreElements"
    xmlns:mmd="http://tfm.faa.gov/tfms/MessageMetaData"
    xmlns:nxcm="http://tfm.faa.gov/tfms/NasXCommonMessages"
    xmlns:idr="http://tfm.faa.gov/tfms/TFMS_IDRS"
    xmlns:xis="http://tfm.faa.gov/tfms/TFMS_XIS"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://tfm.faa.gov/tfms/TFMS_XIS http://localhost:58489/tfms/schema/TFMS_XIS.xsd"
    timestamp="2011-03-15T23:57:59Z">
  <asdiMessage sourceFacility="CCZM" sourceTimeStamp="2011-03-15T23:57:27Z" trigger="TZ">
    <trackInformation>
      <nxcm:aircraftId>UAL966</nxcm:aircraftId>
      <nxcm:speed>470</nxcm:speed>
      <nxcm:reportedAltitude>
        <nxce:assignedAltitude>
          <nxce:simpleAltitude>350</nxce:simpleAltitude>
        </nxce:assignedAltitude>
      </nxcm:reportedAltitude>
      <nxcm:position>
        <nxce:latitude>
          <nxce:latitudeDMS degrees="45" minutes="40" direction="NORTH"/>
        </nxce:latitude>
        <nxce:longitude>
          <nxce:longitudeDMS degrees="056" minutes="58" direction="WEST"/>
        </nxce:longitude>
      </nxcm:position>
   </trackInformation>
  </asdiMessage>
  <asdiMessage sourceFacility="CCM" sourceTimeStamp="2015-03-15T23:57:27Z" trigger="TZ">
    <trackposition>
      <nxcm:aircraftId>UAL936</nxcm:aircraftId>
      <nxcm:speed>470</nxcm:speed>
      <nxcm:reportedAltitude>
        <nxce:assignedAltitude>
          <nxce:simpleAltitude>350</nxce:simpleAltitude>
        </nxce:assignedAltitude>
     </nxcm:reportedAltitude>
      <nxcm:position>
        <nxce:latitude>
          <nxce:latitudeDMS degrees="44" minutes="43" direction="NORTH"/>
        </nxce:latitude>
        <nxce:longitude>
          <nxce:longitudeDMS degrees="062" minutes="42" direction="WEST"/>
        </nxce:longitude>
      </nxcm:position>
    </trackposition>
  </asdiMessage>
</asdiOutput>

I want to extract the values
sourceFacility="CCZM",  sourceTimeStamp="2011-03-15T23:57:27Z", and trigger="TZ"
But the XPath should not return the values for asdiMessage which has a child element called trackposition.
So the following value should not be returned:
asdiMessage sourceFacility="CCM" sourceTimeStamp="2015-03-15T23:57:27Z" trigger="TZ" because the child element.
I tried this /asdiOutput/asdiMessage[not(contains(trackposition))] but this doesn't return anything at all

A: First, fix the typo in the end tag of the root element:
</asdiOuput> should be </asdiOutput>
Next, make sure you have defined a namespace prefix for http://tfm.faa.gov/tfms/TFMS_XIS:
xis="http://tfm.faa.gov/tfms/TFMS_XIS"

Then, this XPath,
/xis:asdiOutput/xis:asdiMessage[not(xis:trackposition)]/@sourceFacility

will select "CCZM" as requested.
You can construct XPaths for sourceTimeStamp and trigger similarly.


text:
Q: FB registration form not showing to anyone else except me I Have a strange issue i integrated Fb Register/Login with my site but strangest thing is it shows me registeration form with all my info pulled from FB when i accept to provide info on facebook but to everyone else it does not show registeration form just logs them in
Very Strange!
Please hav look at snapshot
Thanks!

A: This problem looks like you haven't made your application for this facebook login public.

*

*go to the facebook developers site

*select your application for this login form from the top menu "Apps"

*go to "Status & Review"

*check that "Do you want to make this app and all its live features available to the general public?" is "YES"


text:
Q: How to remove the Xubuntu Login screen in Ubuntu 18.04 (and NOT 14.04) Apart from Gnome I had / have Unity desktop in my Ubuntu 18.04. Later I installed Xubuntu over it. Change the desktop background with windows wallpaper. The same wallpaper was automatically taken by the xubuntu login screen. Later I removed xubuntu, But the unsophisticated login screen with more unpleasant windows wallpaper is still there.
Here, please note that After installing the Ubuntu 18.04 (with Gnome default) for the first time, I installed Unity (as it was my favorite) and the login screen changes into Unitiy (which is the best screen as per my opinion).
Recently, to get rid of Xubuntu login screen (and to check the desktop environment) I installed Ubuntu MATE. But still the login screen is the same xubuntu login screen.
I want to get rid of it. Either  Unity or MATE login screen will be fine.
In a similar post (for Ubuntu 14.04) (How to remove the Xubuntu Login screen in ubuntu 14.04) the below mentioned suggested command solved the issue
"sudo apt-get remove lightdm-gtk-greeter && sudo apt-get install unity-greeter"
But presently Gnome is the default of Ubuntu and not the Unity. And I probably have lightdm as default. And I am a layman (non-technical person). Kindly help me with least technical jargon. If the above command is still applicable in toto or with some modification (like, 'install slick-greeter' instead of 'unity-greeter'), please confirm the same .
Presently it is like-
similar to my left over xubuntu login screen
And I want it to be like-
Unity login screen
PS
Using this command- "sudo apt-get remove lightdm-gtk-greeter'' solved the issue upto 90%. Now I returned back the Unity Greeter which was already have installed there but in inactive state. After that from 'Login Window' app I reintroduce the 'Guest Session' option and change the desktop background to original Ubuntu 18.04 default wallpaper. But the wallpaper has been applied for the guest session (login screen) only. As soon as I choose myself as user the old (windows) wallpaper reappear in the login screen though it is still (my favourite) Unity Greeter interface. Right now I want to change my Greeter Wallpaper only. Please suggest. Kindly note that I am using 'Ubuntu Greeter' and 'lightdm' Desktop Manager.


text:
Q: node.js require files globally I have a problem which i would like to get help with here on stackoverflow.
In my node.js project i have a init.js file which i want to do the following
pseudo code
var variable = require(folder/file).name; (of exported module)
var variable2 = reuire(folder2/file2).name; (of exported module)
variable2.init();

in my init function i am trying to use my var (which in this dummy case) called variable. My catch returns the error that the var called variables is not found. i found that if i use global.variable = require.... then the stuff would work. I though doubt that this is a good way to work in node.js
Why do i want to do it this way? because in my variable2 functions i require other stuff which my variable1 functions is needed (and my init.js is on super top in these layers).
Any tips or help on how to either fix this or structure things better ?

A: You should require the module inside the module where you need it. In your case the line var variable = require(folder/file); should be inside folder2/file2 and not your init.js file.


text:
Q: Summing multiple values into one table I have three tables in Microsoft Access:

*

*Table1 includes the names of various companies and the corresponding unique ID of each (along with other unique information about the company);

*Table2 includes sales information for each company from 2013;

*Table3 includes sales information for each from 2014.
In Tables 2 & 3, a single company is often listed more than once, corresponding to sales in different states.
In Tables 2 & 3, the company name is actually its corresponding ID number, and I'm using a lookup to display the name. Thus, Table1 is the parent of Table2 and Table3.
I want to create a query that lists each company exactly once along with the sum of their sales from Tables 2 & 3. This works fine when I only try to use Table2 OR Table3, but when I incorporate both, the sales are inflated by a constant scalar (a company will show sales exactly 16X what they should be, for example). What's going on here?
Here's what the SQL shows in Access:
SELECT Table2.CompanyName,
       Sum(Table2.TotalRevenue) AS [2013 Revenue],
       Sum(Table3.TotalRevenue) AS [2014 Revenue]
FROM (Table1 INNER JOIN Table2 ON Table1.Company_ID = Table2.CompanyName)
   INNER JOIN Table3 ON Table1.Company_ID = Table3.CompanyName
GROUP BY Table2.CompanyName;

Why is it pulling these Revenue values multiple times? Thank you!

A: First you may consider merge TABLE2 and TABLE3 together and just add a YEAR field. If you keep growing one table for year will be messy in the future.
the problem is you are performing a cartesian product.
[Every company] x [Sales2013] x [Sales2014]

You need
[Every company] x [Sales2013]
UNION
[Every company] x [Sales2014]

Not sure what is the proper syntaxis in Access but you need a calculate totals on the subquery.
And you need LEFT JOIN in case the company didnt sell on that year. (Like a company join on 2014) and COALESCE to convert NULL to 0.
SELECT Table1.*,
       COALESCE(T2.Revenue2013, 0)  Revenue2013,
       COALESCE(T3.Revenue2014, 0)  Revenue2014
FROM Table1
LEFT JOIN ( SELECT CompanyName, SUM(TotalRevenue) as Revenue2013
            FROM Table2
            GROUP BY CompanyName) as T2
       ON  Table1.Company_ID = T2.CompanyName
LEFT JOIN ( SELECT CompanyName, SUM(TotalRevenue) as Revenue2014
            FROM Table3
            GROUP BY CompanyName) as T3
       ON  Table1.Company_ID = T3.CompanyName

A: You are getting multiple values because your Table2 and Table3 are not at the company level. They are at the sales level (I assume). So each table has multiple records for each customer. Joining them on company_id will cause each record in Table2 to join to each record in Table3 for each company_id.
If you want to understand this better, change your query to SELECT * FROM... with the same joins. You'll see for every 2013 record, there are many 2014 records. It won't make any sense, therefore your aggregation won't make much sense.
Instead, consider summing them before joining like:
SELECT Table2.CompanyName,
       t2.TotalRevenue AS [2013 Revenue],
       t3.TotalRevenue AS [2014 Revenue]
FROM
    Table1
    INNER JOIN (SELECT Company_Id, CompanyName, sum(TotalRevenue) as TotalRevenue FROM Table2 GROUP BY COmpany_ID, CompanyName) as t2 ON Table1.Company_ID = T2.CompanyName)
    INNER JOIN (SELECT Company_Id, CompanyName, sum(TotalRevenue) as TotalRevenue FROM Table3 GROUP BY COmpany_ID, CompanyName) as t3 ON Table1.Company_ID = T3.CompanyName
GROUP BY T2.CompanyName;

A: This happens because you are performing the aggregation after joining your tables. As an example
Table 1
Company_Id, CompanyName
1           One
2           Two
3           Three

Table 2 (2013)
Company_name, State, Sales
1             CA     50
1             WA     70
2             AK     30

Table 3 (2014)
Company_name, State, Sales
1             CA     60
1             WA     90
2             AK     50

Based on your query, first the sum of table 2 is performed, obtaining on memory:
Company_Id, Sales_2013
1           150
2           50

After the join with 2014 is performed, obtaining Still on memory:
Company_Id, Sales_2013, State_2014, Sales_2014
1           150        CA           50
1           150        WA           90
2           50         AK           30

As you can see at this point you have duplicates. Then, the second sum is performed, finally obtaining
Company_Id, Sales_2013, Sales_2014
1           300         140
2           50          30

For this to do what you expect you need to have a query that does:
SELECT TTable2.CompanyName,
   [2013 Revenue],
   [2014 Revenue]
FROM Table1 INNER JOIN (
    SELECT Table2.CompanyName,
        Sum(Table2.TotalRevenue) AS [2013 Revenue]
    FROM Table2
    GROUP BY Table2.CompanyName
)TTable2
ON Table1.Company_ID = TTable2.CompanyName
INNER JOIN (
    SELECT Table3.CompanyName,
        Sum(Table3.TotalRevenue) AS [2014 Revenue]
    FROM Table3
    GROUP BY Table3.CompanyName
)TTable3
ON Table1.Company_ID = TTable3.CompanyName;


text:
Q: Toggle format of gnome terminal prompt string by command? My terminal has a default prompt format like this one:

username@boxname /path/to/current/directory $

The code that produces it looks like this: (it has some color definitions too)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'

If the path to the current directory gets too long it becomes unpleasant to work with the terminal because you constantly break lines. In such cases I would prefer a format that produces a shorter string like this one:

username@boxname current_dir_name $

The code that produces it would look like this (again with color):
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'

Does anyone know how I could easily toggle the format of the current terminal window from one style to the other by just typing for example: prompttoggle?

A: You can use a tiny bash function:
prompttoggle () {
    if [[ $PS1 = *basename* ]]; then
        export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'
    else
        export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'
    fi ;}

The function above matches if the current $PS1 contains basename, if yes, then the PS1 without basename is set otherwise the one with basename is set.
Put the function in your ~/.bashrc to get it available in all interactive sessions.
Example:
foo@bar:~/spam/egg$ prompttoggle () {
>     if [[ $PS1 = *basename* ]]; then
>         export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'
>     else
>         export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'
>     fi ;}

foo@bar:~/spam/egg$ prompttoggle

foo@bar egg $ prompttoggle

foo@bar ~/spam/egg $

A: Or... make two very tiny functions and add to the end of your ~/.bashrc
# short prompt
promptshort() { export PS1=$(echo "$PS1" | sed 's/\\w/\\W/g') ; }

# full length prompt
promptlong() { export PS1=$(echo "$PS1" | sed 's/\\W/\\w/g') ; }

for a shortened prompt, type promptshort, to go back to the full path, type promptlong
\W shows the current working directory only so $(basename ${PWD}) is overkill imho

You could combine into one function but "long" and "short" are descriptive and both have less keystrokes than "toggle" ;)
Instead of adding a line to override PS1 I prefer to tweak the code that sets it (for example, uncomment force_color_prompt=yes and edit the line after [ "$color_prompt" = yes ]; then)

A: Here's a ~/.bashrc function definition that I personally use to reset/toggle my prompt from regular prompt to just $. Adapt it as necessary to suit your needs.
resetps() {
    if [ "$PS1" = "$ " ]
    then
        PS1=$OLDPS1
    else
        OLDPS1=$PS1
        export OLDPS1
        PS1="$ "
    fi
}

A: Store both your long and short PS1 variables under a different name:
PS1short='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'
PS1long='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'

Make sure to set PS1to one of them initially:
PS1="$PS1long"

Then you can make an alias like this to toggle between the two PS1 values:
alias prompttoggle='if test "$PS1" = "$PS1long" ; then PS1="$PS1short" ; else PS1="$PS1long" ; fi'

Adding all four lines to your ~/.bashrc file will ake the command available in your Bash sessions, here are they again for easier copying:
PS1short='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'
PS1long='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'
PS1="$PS1long"
alias prompttoggle='if test "$PS1" = "$PS1long" ; then PS1="$PS1short" ; else PS1="$PS1long" ; fi'

A: This is an answer to your problem (long directories break the command line) and not specifically to your question (how to change the command prompt on the fly.)
I solved this problem years ago with this prompt:
PS1='\[\e[32;1m\]$? \u@\h \[\e[35;1m\]\w\[\e[m\]\n\$ '
#    └──green───┘         └──purple──┘  └─norm─┘

What this does:

*

*output the exit value of the previous command (this is incredibly useful)

*output the current user and host in one color

*output the working directory in another color (adjust the colors to your taste)

*output the dollar and space on a new line, ending the color sequences before the line break

This gives you all the space you need for your command, does not shift it right when you are in a deep directory structure, does not mangle the typing line with color codes (avoiding strange bugs that happen sometimes), while still giving you the colored hint on where the output of one command ended and the next one begun:


text:
Q: Consuming "Event Tracing for Windows" events An answer to this question has led me to look into using "Event Tracing for Windows" for our tracing needs. I have come across NTrace, which seems to be a good way to produce ETW events from C# code (using the XP-compatible "classic provider" model).
However, I am unable to find an easy way to consume these events - to see them in real-time and/or log them to a file. The only way I have found is that described in the NTrace documentation: using a tool which is only available as part of the Windows DDK.
In the case of a complex problem in the field, we may need to ask the user to produce a file containing a trace. We can't ask users to download the DDK or carry out a number of complex operations in order to do this.
Is there a straightforward, user-friendly way to log ETW events to a file?
Also, is it possible for someone to consume ETW events on Windows Vista/7 if they are not running as administrator?

A: Windows Event Log reads the ETW. In fact I'd say this is the correct way for a consumer (non program) to view and export the ETW traces.
See here for an example. http://blogs.microsoft.co.il/blogs/applisec/archive/2009/10/12/reading-etw-tracing-using-event-viewer.aspx
This question on msdn Discuses what to do when the logs don't appear. Does anything here help?

A: TraceView is the easiest out-of-the-box solution, but it is possible to write your own ETW viewer that is specific to your provider.  This would give you full control over the presentation and make it much easier on the end user as TraceView is really more of a debugging tool than something you can ask end users to run.
As far as real-time tracing goes, according to the documentation:

Only users with administrative privileges, users in the Performance Log Users group, and services running as LocalSystem, LocalService, NetworkService can consume events in real time. To grant a restricted user the ability to consume events in real time, add them to the Performance Log Users group.
Windows XP and Windows 2000:  Anyone can consume real time events.

If you're interested in writing your own ETW viewer (real-time or log file), here is the relevant documentation.

A: ETW tracing was designed to run only by administrators because trace may contain personal identifiable information. And it would pose security threat if a non-admin can capture the trace.
Here is a warning Example from xperf
The trace you have just captured "C:\Windows\system32\kernel.etl" may contain
personally identifiable information, including but not necessarily limited to paths to files accessed, paths to registry accessed and process names. Exact information depends on the events that were logged. Please be aware of this when sharing out this trace with other people.
Hope this answers your question

A: Here is how you can get custom ETW traces from your own  custom provider and how ETW can be used within managed code
Hope this helps.

A: IMO Perfview is one of the best tools available to control and view ETW traces. It can also provide managed call-stacks. The best part of it is you could xcopy on to any server and collect traces.
Perfview uses TraceEvent library and here the samples how you could use it using an API and C#


text:
Q: How to get input provided in a textarea tag using JavaScript? Have a textarea tag in form, to take input text and return the value of said text.
 <textarea id="code" name="code"></textarea>

Using javascript to get the value, but it returns nothing. Used typeof to check if it's undefined, but typeof text gives 'string'. Is this correct way to use .value? How to improve this?
JavaScript:
var text = document.getElementById('code').value;

document.getElementById('submit-button').onclick = function() {
    alert(text);
};

A: You're getting the value immediately when the page loads, before the user has had a chance to type anything.  You want to get the value when the user clicks the button:

document.getElementById('submit-button').onclick = function() {
    var text = document.getElementById('code').value;
    alert(text);
};
<textarea id="code" name="code"></textarea>
<button type="button" id="submit-button">click me</button>

A: You need to bind the event and get the value just when the user clicks the button.
Embrace the function addEventListener

document.getElementById('submit-button').addEventListener('click', function() {
    var text = document.getElementById('code').value;
    console.log(text);
});
<textarea id="code" name="code"></textarea>
<button type="button" id="submit-button">click me</button>

A: Stick the var text line inside the click event; it's getting defined when the script runs originally, so it is just an empty string.
document.getElementById('submit-button').onclick = function() {
    var text = document.getElementById('code').value;
    alert(text);
};


text:
Q: Get rid of Duplicates in SQL Report Drop down Parameter (SharePoint Report embedded) Is it possible to have a drop down parameter only show a unique value if I have multiple values? If I have 5 items with 123, I only want 123 to show up once in the drop down.
Currently I have a DataSet with one field showing Job_Number. I have the Parameter @JobNumber looking at that field but it is showing multiple items in the drop down with the same values. I tried adding filters but got errors saying:

Forward dependencies are not valid.

Any help would be appreciated.

A: I figured it out see link below if anyone else is running into this issue.
http://blogs.msdn.com/b/sqlforum/archive/2011/04/28/walkthrough-how-to-get-distinct-values-of-a-column-of-a-sharepoint-list-using-sql-server-reporting-services.aspx


text:
Q: Math functions within Linq to Entities I have some older methods using sql strings and connections that I'm trying to convert to Linq to Entities.
I have rewritten the sql to an ef query as follows;
Using ctx As New DataEntities()
        Dim station As String = (From sta In ctx.weather_stations
                                 Let distance = SqlFunctions.SquareRoot(Math.Pow(69.1 * (sta.latitude - lat), 2) + Math.Pow(69.1 * (longi - sta.longitude) * SqlFunctions.Cos(sta.latitude / 57.3), 2))
                                 Where distance < withinRange
                                 Order By distance
                                 Select sta.station_id).Take(1).ToString()
        If Not String.IsNullOrEmpty(station) Then
            Return station
        Else
            Return String.Empty
        End If
    End UsingData

This gives an error,
LINQ to Entities does not recognize the method 'Double Sqrt(Double)' method, and this method cannot be translated into a store expression.
Can this query be done in Linq to EF? If so, how can I reconstruct this query to work?


text:
Q: Как сделать чтобы скрытый блок появлялся? Необходимо что бы при клике по img2, вместо block-1 появлялся скрытый блок block-5. Нужен совет или реальная помощь, ибо голова уже вообще не варит. Спасибо.jsfidle

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia error vero voluptatibus optio qui ea eaque, delectus ad velit tenetur deleniti eum quia fugiat, magni recusandae esse, enim atque nam?

Ipsum dolor

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam inventore modi dolorum voluptatum tempore consequatur molestiae id optio expedita aliquid amet, praesentium excepturi quod

Consectetur

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi quia asperiores sint, rem minus esse rerum ullam expedita exercitationem voluptates culpa soluta quidem atque neque cumque inventore at dicta aperiam.

Repellat dolore

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat dolore temporibus enim perferendis modi officia soluta, quis, optio voluptatibus dolorum vitae in dolor obcaecati vel laborum facere, ea doloribus asperiores!

.wrapp{
  width: 100%;
  margin: 0 auto;
}
   .block-1, .block-2, .block-3, .block-4{
     width: 43%;
     border: 1px solid red;
     display: inline-block;
     height: auto;
     margin: 10px 3% 10px 0;
     padding: 0 10px;
 }
   .block-2{
    border: 1px solid green;
}
 .block-3{
    border: 1px solid blue;
}
 .block-4{
   border: 1px solid yellow;
}
 h2{
   text-align: center;
}

  /*скрытый блок
  .block-5{
   width: 43%;
   border: 1px solid black;
   display: inline-block;
   height: auto;
   margin: 10px 3% 10px 0;
   padding: 0 10px;
 }*/

jQuery:
 $('.img2').click({
  $('.block-1').hide();
  $('.block-5').show();
 });

A: А где у вас class img2 и, собственно, block-2? Вот с поправленным вариантом:

$(document).ready(function() {
    $(".img2").on("click", function(){
        if ($('.block-1').css("display") == "inline-block") {
            $('.block-1').hide();
            $('.block-5').css("display", "inline-block");
        } else {
            $('.block-5').hide();
            $('.block-1').css("display", "inline-block");
        }
    });
});
.wrapp{
    width: 100%;
    margin: 0 auto;
}
.block-1, .block-2, .block-3, .block-4{
    width: 43%;
    border: 1px solid red;
    display: inline-block;
    height: auto;
    margin: 10px 3% 10px 0;
    padding: 0 10px;
}
.block-2{
    border: 1px solid green;
}
.block-3{
    border: 1px solid blue;
}
.block-4{
    border: 1px solid yellow;
}
h2{
    text-align: center;
}

.block-5 {
    width: 43%;
    border: 1px solid black;
    display: none;
    height: auto;
    margin: 10px 3% 10px 0;
    padding: 0 10px;
}

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia error vero voluptatibus optio qui ea eaque, delectus ad velit tenetur deleniti eum quia fugiat, magni recusandae esse, enim atque nam?

Repellat dolore

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat dolore temporibus enim perferendis modi officia soluta, quis, optio voluptatibus dolorum vitae in dolor obcaecati vel laborum facere, ea doloribus asperiores!

Ipsum dolor

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam inventore modi dolorum voluptatum tempore consequatur molestiae id optio expedita aliquid amet, praesentium excepturi quod

Consectetur

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi quia asperiores sint, rem minus esse rerum ullam expedita exercitationem voluptates culpa soluta quidem atque neque cumque inventore at dicta aperiam.

Repellat dolore

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat dolore temporibus enim perferendis modi officia soluta, quis, optio voluptatibus dolorum vitae in dolor obcaecati vel laborum facere, ea doloribus asperiores!


text:
Q: Retrieving Dailymotion popular videos I want to retrieve popular videos on Dailymotion without login. Youtube has an API for the same. Is there any API available to perform this task?

A: You need to use the "sort" parameter with rated, visited ...
Something like https://api.dailymotion.com/videos?sort=visited
See here for more infos.


text:
Q: Google search and integrating with my own search I was wondering where i should start in trying to have a search bar that searches my database but also searches google shopping to return results.
They can be separated with a "Google search results" heading and a "This database results"
Any ideas?
I found this page, but cannot find a shopping results option:
https://developers.google.com/web-search/docs/#The_Hello_World_of_Google_Search

A: This url returns a json object with search results.
Just grab an API key from google and you're on your way.
https://www.googleapis.com/shopping/search/v1/public/products?key=KEYGOESHERE&country=US&q=SEARCH+TERMS+GO+HERE&alt=json


text:
Q: UNION function mysql not accepting ORDER BY date Im trying to extract data using this query:
select fnl_res.id, fnl_res.business_name, fnl_res.owner_name from (
(select b_infos.id, b_infos.business_name, b_infos.owner_name, orders.date from b_infos
    inner join orders on b_infos.id = orders.businessId)
UNION
( select b_infos.id, b_infos.business_name, b_infos.owner_name from b_infos
    inner join expenses_logs on b_infos.id = expenses_logs.businessId ) ) as fnl_res

It works fine but when i add a column date and order by date on each union:
select fnl_res.id, fnl_res.business_name, fnl_res.owner_name, orders.date from (
(select b_infos.id, b_infos.business_name, b_infos.owner_name, orders.date from b_infos
    inner join orders on b_infos.id = orders.businessId ORDER BY orders.date)
UNION
( select b_infos.id, b_infos.business_name, b_infos.owner_name, expenses_logs.date from b_infos
    inner join expenses_logs on b_infos.id = expenses_logs.businessId  ORDER BY expenses_logs.date ) ) as fnl_res

I got this error:
Error code 1114: The table is full!
Already research this error says im trying to insert but im just selecting on the table
Is there something i need to consider?

A: In MySQL, order by may not appear within a subquery. Wrap the whole query up as a subquery and apply order by to that:
select *
from (
  select
    b_infos.id, b_infos.business_name, b_infos.owner_name, orders.date
    from b_infos
    join orders on b_infos.id = orders.businessId
  union
  select
    b_infos.id, b_infos.business_name, b_infos.owner_name, expenses_logs.date
    from b_infos
    join expenses_logs on b_infos.id = expenses_logs.businessId
) x
order by 4 -- order by the 4th column

Note that without where clauses, you're going to return every row, possibly blowing memory and causing your error. Consider some filtering, perhaps where orders.date > '2022-10-13'


text:
Q: Add current date to HTML with JS / Javascript I'm making a Note app to learn Polymer and stuck with date implementation. I have this chunk of code:
<template>

  [[data.name]]

    [[data.description]]

</template>

What i need to get is a text saying: 'Created on Jul 23, 2018 UTC...'
Tried with last line of code and i get: Cannot set property 'innerHTML' of null;
Question 2: is there a way to add current date via
static get properties() {
          return {
              data: {
                  type: Object,
                  value: undefined
              }
          }
      }

Add something like date: new Date('Jul 23, 2018') to 'data' obj ?

A: getElementsByClassName returns an array. If you only need the first instance of the array you can do something like this.
const [dateCreated] =   document.getElementsByClassName("date-created");

dateCreated.innerHTML = `<p> created on: ${new Date()}</p>`;

If you have multiple elements with the same date, then just loop
document.getElementsByClassName("date-created").forEach(el => {
  // do something
});

As for your second question. More than likely.


text:
Q: How i show f is integrable and calculate its integral. Let $a < b$ and $f\colon [a, b] \to \mathbb{R}$ be a step function, that is, there exist a partition
$$P = (a = x_0 < x_1 < \cdots < x_n = b)$$ and numbers $c_1,c_2,\ldots, c_n$, such that for all
$j = 1,\ldots,n, f(x) = c_j$ for all $x \in (x_{j-1}, x_j ]$. How do I show $f$ is integrable and calculate its integral?

A: Hint: Show that for any refinement of $P$ the upper and lower partial sums are not altered. Moreover, that $L(f,P')=U(f,P')$ for any refinement $P'$ of $P$.

A: Let $f : [a,b] \rightarrow \mathbb{R}$. We know that every bounded monotonic function is integrable, and furthermore that every bounded piecewise monotonic function is integrable by the additive property of integrals with respect to the integrand, over an interval. Since $f$ is a step function, it is a bounded piecewise monotonic function, and consequently integrable over $[a,b]$. To compute the value of $\int_a^b f(x)~dx$, we recall that the integral from $a$ to $b$ of a constant function $g(x) = c$ is $c(b - a)$ and apply the additive property of integrals to obtain $\int_a^b f(x)~dx = \int_{x_0}^{x + 1} f(x)~dx + \ldots + \int_{x_{n - 1}}^{x_n} f(x)~dx$, where $P = \{x_0,\ldots,x_n\}$ is a partition of $[a,b]$ such that $f(x)$ is constant on each open subinterval of $P$.


text:
Q: Can one "cheat" refcheck to make unreferenced equations be as if they were referred to? My problem is the following. I have three equations
\begin{equation}
\label{eq1}
a=bc
\end{equation}

\begin{equation}
\label{eq2}
v=ut
\end{equation}

\begin{equation}
\label{eq3}
f=gh
\end{equation}

Later in the document, I refer to the three of them as \eqref{eq1}--\eqref{eq3}, thus the refcheck package tells me eq2 has not been referred to. Is there any way to "make refcheck understand" that eq2 has been referred to?

A: You can \eqref{eq2} in a way that is not tyepeset, namely, in a temporary \setbox.  Here, I've made that into the macro \phantomref{}.
\documentclass{article}
\usepackage{refcheck,amsmath}
\newcommand\phantomref[1]{\setbox0=\hbox{\eqref{#1}}}
\begin{document}
\begin{equation}
\label{eq1}
a=bc
\end{equation}

\begin{equation}
\label{eq2}
v=ut
\end{equation}

\begin{equation}
\label{eq3}
f=gh
\end{equation}

In \eqref{eq1}--\eqref{eq3}\phantomref{eq2}, we see lots of variables.
\end{document}


text:
Q: How can I run multilevel longitudinal model in R without list wise deletion? I'm running a longitudinal model with time as the only predictor using R. I have also run it in HLM and SAS, which used maximum likelihood without listwise deletion. The results were the same. However, the results from R were slightly different. I think it might due to missing data. Here are my codes:

library(nlme)
  model.b <- lme(Y ~ TIME , data=d, na.action = na.exclude, random= ~ TIME | ID, method="ML")

A: SAS (prox mixed), HLM, and R (lme) handle missing data in exactly the same way -- namely by deletion of each row of the dataset where either the outcome or any of the predictor variables are missing. Therefore, this is not the reason why results from R were slightly different.
If you don't want to handle missing data that way, you will have to look into things like multiple imputation to first generate a complete dataset based on some sensible imputation model and then averaging parameter estimates as described by Rubin (1987).
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York: Wiley & Sons.


text:
Q: What subset of physics can be described in complex phase space? By complex phase space I mean $z=q + i\,p \in \mathbb{C}^{n}$ and  $z = q -i \, p \in \mathbb{C}^{n}$ and the Hamiltonian $H(z,\bar{z})$ is a function of $z, \bar{z} \in \mathbb{C}^{n}$.

A: What follows doesn't completely answer your question but hopefully it can be useful.
A classical example of an hamiltonian $H(p,q)$ which can be reduced to the form $H(z_+,z_-)$ with $z_{\pm}=\alpha q \pm i \beta p$ is the harmonic oscillator. The hamiltonian of an harmonic oscillator is
$$H(p,q)=\frac 1 {2m} [p^2 + m \omega q^2]$$
Using the identity
$$p^2+m \omega q^2 = (p+i q \sqrt{m \omega})(p-i q \sqrt{m \omega})$$
we see that we can write the hamiltonian as
$$H(p,q) = \frac 1 {2m}  (p+i q \sqrt{m \omega})(p-i q \sqrt{m \omega})\\= \left(\frac p {\sqrt{2m}} + i  q  \sqrt{\frac \omega {2}}\right) \left(\frac p {\sqrt{2m}} - i  q  \sqrt{\frac \omega {2}}\right)$$
and defining
$$z_{\pm} = \left(\frac p {\sqrt{2m}} \pm i  q  \sqrt{\frac \omega {2}}\right)$$
we obtain
$$H(z_+,z_-) = z_+ z_-$$
The same trick can be used whenever $p,q$ appear as couples of quadratic terms in the hamiltonian. In quantum mechanics, this trick leads to the definition of the creation and annihilation operators.


text:
Q: What are possible approaches for learning causal DAG of events? I have historical data of event logs.
Each event has an associated contextual Id, which can be used to tell that event A happened first in some context, then event B happened in same context and then C and so on.
I want to use this data to find which events are causing other events ( in a context) represented in DAG form. Which machine learning approaches can be used for this type of task?
I know Bayesian causal networks is one approach. Are there any others?

A: Traditionally DAG's refer to probabilistic graphical models, specifically used by Bayesian networks (BN's), which have fallen out of fashion (blown out of water) by neural nets.
While directionality is clear, causality has additional implications and is a debatable aspect of Bayesian Networks (see statistical indistinguishability of DAG's etc.). Basically you can get identical Bayesian scores for different DAG's while structure learning of BN's.
There is also the concept of DAG's for deep learning, see an example here. Some call these DAG networks, where the layers can be arranged as a directed acyclic graph. DAG networks can have a more complex architecture where layers can have inputs from, or outputs to, multiple layers.
Finally, anytime you hear anyone having strong claims about DAG's and causality, take whatever they say with a pinch of salt(!).

A: Chain event graphs are a more generic version of a Bayesian network that are particularly suited for context-specific event information. This paper shows how to refine a BN into a chain event graph.
In the Art of Causal Conjecture, Shafer talks about how questions of cause are more naturally suited to events.


text:
Q: UISearchDisplayController Cancel Button Truncated? I have a UISearchDisplayController setup with the standard UISearchBar. I customized the font of the cancel button and it worked fine. The issue I'm having is that from search I can push a new view controller onto the stack after tapping a search result. That works seamlessly, but when I "go back" the cancel button gets truncated. I tried decreasing the font size and it makes no difference. The text starts out fine, but after navigating forward and back it gets truncated.
Any ideas on how I could fix this?


text:
Q: How to convert a monolithic CSV String into a List? I have a CSV stored in a String:
Abc, Def, Ghi, Jkl, Mno[CR|LF]
Abc, Def, Ghi, Jkl, Mno[CR|LF]
Abc, Def, Ghi, Jkl, Mno[CR|LF]
Abc, Def, Ghi, Jkl, Mno[CR|LF]

When I open the file in Notepad++ and use "Show All Characters" I see the newline character at the end of each line represented by the [CR|LF] notation I indicated above.
How do convert this monolithic String into a List<String> where each line above represents a separate String in the List but without the [CR|LF] characters?

A: I think it should be as simple as:
String allData /* = readCSVFromFile() */;
String[] rows = allData.split("\r\n");
List<String> rowList = Arrays.asList(rows);

A: Use a BufferedReader. Something like this:
List<String> rows = new ArrayList<String>();
BufferedReader r = new BufferedReader(new FileReader("file.csv"));
String line = null;
while ((line = r.readLine()) != null)
{
    rows.add(line);
}


text:
Q: Can't read property value of null So I'm trying to make a Shopping Cart using HTML, CSS, Javascript, and JQuery. Whenever you click Add to Cart under the orange it will make almost all of the HTML elements disappear and only display the table Shopping Cart. But when you change the quantity and click Update Cart, I am getting an "Uncaught TypeError: Cannot read property 'value' of null Shopping Cart" in the console. I've looked everywhere to find a solution to this but couldn't find one. I appreciate the help.
https://jsfiddle.net/John_Badew/er9z3kg1/10/

$(document).ready(function() {
  $("#bButton").click(function() {
    $(".sTable").append("Banana</td");
    $(".sTable").append("<form><input id = 'bupdateQuantity' type='number' name='quantity' min='1'max='10'></form>	");
    $(".sTable").append("50 cents	");
    $(".sTable").append("	");

  });
});

$(document).ready(function() {
  $("#oButton").click(function() {
    $(".sTable").append("Orange</td");
    $(".sTable").append("<form><input id = 'oupdateQuantity' type='number' name='ooquantity' min='1'max='10'></form>	");
    $(".sTable").append("75 cents	");
    $(".sTable").append("	");

  });
});

$(document).ready(function() {
  $("button").click(function() {
    $(".disappear").hide();
  });

});

$(document).ready(function() {
  $(".button").click(bquantity)
  $(".button").click(oquantity)

});

function bquantity() {
  var quantity = document.getElementById('bupdateQuantity').value;
  var price = quantity * .5;
  var bPrice = document.getElementById('bPrice');
  bPrice.innerHTML = "$" + price;
}

function oquantity() {
  var oquantity = document.getElementById('oupdateQuantity').value;
  console.log(oquantity);
  var oprice = oquantity * .75;
  var oPrice = document.getElementById('oPrice');
  oPrice.innerHTML = "$" + oprice;
}
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

li {
  float: left;
}

li a {
  display: block;
  color: aqua;
  text-align: center;
  padding: 14px 16px 14px 16px;
  text-decoration: none;
}

li a:hover {
  color: black;
  border-bottom: 1px solid black;
}

.button {
  background-color: #4CAF50;
  /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin-top: 50px;
}

.button:hover {
  color: #4CAF50;
  background-color: white;
}

.sTable {
  border-collapse: collapse;
  width: 75%;
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="style.css">

Home

Cart

Banana

Orange

Apple

50 cents per bunch

75 cents per orange

60 cents per apple

      <button id="bButton">Add To Cart</button>
      <button id="oButton">Add To Cart</button>
      <button id="aButton">Add To Cart</button>

    Item Name
    Quantity
    Price
    Total

  Update Cart

A: Here's the problem:
$(document).ready(function(){
  $(".button").click(bquantity)
  $(".button").click(oquantity)
});

On "Update" button click event you update both bquantity and oquantity but you don't have both html created. You only have the one related to the button clicked (bButton/oButton). You have to separate these events.


text:
Q: Tell me that I exceeded the max title length (150 chars) before I remove focus from the title box I was writing a pretty long title and nobody told me that I reached 196 chars already... everything seemed to be ok.

But then I removed focus from the title box and... suddenly saw that apparently I have already written more than 150 chars!

Could it tell me before I remove the focus? I mean, it should say that I exceeded the limit while I am writing, not after I write my title.


text:
Q: Enable Web sharing in mac sierra and access the server from outside I a running rails app in my local in port 3000. I can access the app by hitting the local host or http://10.55.18.22:3000/ but i am not able to access the site from other devices(in the same network).
How can i make this accessible from outside my mac machine also?
Kindly note that web sharing option is not available in mac sierra.
Thanks in advance.