text:
Q: Apollo Link State Default Resolver Not Working (@client query parameter variables) Example here: https://codesandbox.io/s/j4mo8qpmrw
Docs here: https://www.apollographql.com/docs/link/links/state.html#default
TLDR: This is a todo list, the @client query parameters don't filter out the list.

This is the query, taking in $id as a parameter
  const GET_TODOS = gql`
    query todos($id: Int!) {
      todos(id: $id) @client {
        id
        text
      }
    }
  `;

The query passes the variable in there
<Query query={GET_TODOS} variables={{ id: 1 }}>

  /* Code */

</Query>

But the default resolver doesn't use the parameter, you can see it in the codesandbox.io example above.
The docs say it should work, but I can't seem to figure what I'm missing. Thanks in advance!

A: For simple use cases, you can often rely on the default resolver to fetch the data you need. However, to implement something like filtering the data in the cache or manipulating it (like you do with mutations), you'll need to write your own resolver. To accomplish what you're trying to do, you could do something like this:
export const resolvers = {
  Query: {
    todos: (obj, args, ctx) => {
      const query = gql`
          query GetTodos {
            todos @client {
              id
              text
            }
          }
        `
      const { todos } = ctx.cache.readQuery({ query })
      return todos.filter(todo => todo.id === args.id)
    },
  },
  Mutation: {},
}

EDIT: Every Type we define has a set of fields. When we return a particular Type (or List of Types), each field on that type will utilize the default resolver to try to resolve its own value (assuming that field was requested). The way the default resolver works is simple -- it looks at the parent (or "root") object's value and if it finds a property matching the field name, it returns the value of that property. If the property isn't found (or can't be coerced into whatever Scalar or Type the field is expecting) it returns null.
That means we can, for example, return an object representing a single Todo and we don't have to define a resolver for its id or text fields, as long as the object has id and text properties on it. Looking at it another way, if we wanted to create an arbitrary field on Todo called textWithFoo, we could leave the cache defaults as is, and create a resolver like
(obj, args, ctx) => obj.text + ' and FOO!'

In this case, a default resolver would do us no good because the objects stored in the cache don't have a textWithFoo property, so we write our own resolver.
What's important to keep in mind is that a query like todos is just a field too (in this case, it's a field on the Query Type). It behaves pretty much the same way any other field does (including the default resolver behavior). With apollo-link-state, though, the data structure you define under defaults becomes the parent or "root" value for your queries.
In your sample code, your defaults include a single property (todos). Because that's a property on the root object, we can fetch it with a query called todos and still get back the data even without a resolver. The default resolver for the todos field will look in the root object (in this case your cache), see a property called todos and return that.
On the flip side, a query like todo (singular) doesn't have a matching property in the root (cache). You need to write a resolver for it to have it return data. Similarly, if you want to manipulate the data before returning it in the query (with or without arguments), you need to include a resolver.


text:
Q: detecting a whitespace string considering we have following strings and we are going to write them into a text file:
String a="        "
String b="  "
String c="java "
String d=" java"
String e="java"

but because a and b has no character , we have no interest to insert them into the file.
maybe here its easy to see them and ignore them, but what if there is a DOM tree and we get nodes text one by one and because of lots of white spaces in the page, there are lots of white space strings like [#text:            ] in the DOM .
what is the way to find out strings like  a and b as blanks and then ignoring them to right it into a text?

A: s.trim().length() == 0;

or
s.trim().isEmpty();

or
s.matches("\\s*");

or
StringUtils.isBlank(s);

(that one needs Jakarta Commons Lang). I personally go with the last one as it's null-safe to boot.

redpajama_set_name: RedPajamaStackExchange


text:
Q: What determines voltage levels in RS-232 What determines the peak voltage levels for RS-232 lines? Is it determined by the software? The hardware? Something else?

A: The RS-232 standard specifies the range as:
0 (space)   Asserted    +3v to +15v
1 (mark)    Deasserted  −15v to −3v

In addition, inputs must tolerate voltages up to ±25v, and outputs must tolerate indefinite shorts to ground.
In the past, a lot of equipment used ±12v since it was available from a minicomputer power supply for example. Once personal computers became popular, most of them switched to ±5 since it is commonly available and still within the spec.  (Well, the +5 is commonly available, additional circuitry is necessary to get the -5V if the main power supply does not provide it.)
As an example, the MAXIM series of UART RS-232 interface chips such as the MAX220-MAX249 series use a voltage doubler and voltage converter to generate ±10v.)

A: Voltage levels are determined by the HW drivers. A typical driver has a switched capacitor power supply to transform from logic levels to RS232 bipolar levels

A: Specifically the voltage levels for mark and space are determined by the power supply rails of the transmitting circuit. The software neither knows nor cares what voltages represent mark or space (0 or 1). As long as the receiving circuit can discern the difference. In some cases it is not unusual to find simple TTL levels (0 and 5V) in modern digital equipment decades removed from the vintage technology.


text:
Q: How to CompleteCheckoutSession for PHP Amazon Pay SDK? I've follow the instruction how to integrate Amazon V2 for PHP
https://github.com/amzn/amazon-pay-api-sdk-php

But I could not find any section how can I implement the Complete Checkout Session function in order to get "chargeID".
Here is what I've implement
$payload = array(
    'webCheckoutDetails' => array(
    "checkoutResultReturnUrl" => HTTPS_SERVER . "index.php?route=payment/amazon/returnURL"
),
'paymentDetails' => array(
    'paymentIntent' => 'Authorize',
    'canHandlePendingAuthorization' => false,
    'chargeAmount' => array(
        'amount' => (int)$total_amount,
        'currencyCode' => 'JPY'
    ),
),
'merchantMetadata' => array(
    'merchantReferenceId' => $order_id,
    'merchantStoreName' => 'MWYW Online Store',
    'noteToBuyer' => 'Thank you for your order!'
)
);

try {

$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->updateCheckoutSession($checkoutSessionId, $payload);

$payload = array(
    'chargeAmount' => array(
            'amount' => (int)$total_amount,
            'currencyCode' => 'JPY'
        ),
);

$result = $client->completeCheckoutSession($checkoutSessionId, $payload);

But I got the error message like this
{"reasonCode":"InvalidCheckoutSessionStatus","message":"You tried to call an operation on a Checkout Session that is in a state where that operation is not allowed"}
Could you please tell me what's wrong with my code?

A: The result of ::updateCheckoutSession() will give you a amazonPayRedirectUrl in webCheckoutDetails. You need to redirect the client to this URL.
After the client has finished their input on that external page they will be redirected back to your checkoutResultReturnUrl. At this point you will be able to complete the CheckoutSession.

A: Update Checkout Session response will include a Constraint object until all mandatory parameters have been provided. (mandatory parameters: checkoutResultReturnUrl, chargeAmount, paymentIntent)
Once there are no constraints, the response will return a unique amazonPayRedirectUrl. Redirect the buyer to that URL to have Amazon Pay run the transaction. Then the buyer will be redirected to checkoutResultReturnUrl after Amazon Pay has processed the transaction (including any decline flows if necessary). The Amazon Pay checkout session ID will be included as a query parameter on checkoutResultReturnUrl.

A: $headers = array('x-amz-pay-Idempotency-Key' => uniqid()); // added externally

$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->updateCheckoutSession($checkoutSessionId, $payload , $headers);

This Worked for me for getting the web checkout details  data in $response


text:
Q: Rails: Two different many to many relationships between two models I have two tables named books (id, name, author_name) and users (id, name, location). A book can either be viewed by a user or edited by a user. So, for these two relationships I have two join tables viz. book_editor_users (book_id, user_id) and book_viewer_users (book_id, user_id).
How do I model this in Rails such that I can retrieve editor users and viewer users like this:
Book.find(1).book_editor_users
Book.find(1).book_viewer_users

My attempt for the book and user model are:
class Book < ActiveRecord::Bas
  has_many :book_editor_users
  has_many :users, through: :book_editor_users
  has_many :book_viewer_users
  has_many :users, through: :book_viewer_users # I am confused on how to setup this line
end

class User < ActiveRecord::Base
  has_many :books, through: :book_editor_users
  has_many :books, through: :book_viewer_users # I am confused here too
end

Join models I have written are:
class BookEditorUser < ActiveRecord::Base
  belongs_to :book
  belongs_to :user
end

class BookViewerUser < ActiveRecord::Base
  belongs_to :book
  belongs_to :user
end

There is another work around that I thought of, but I am not sure whether it is the Rails way. That work around is to have a single join table book_users (book_id, user_id, type) where the type column can capture whether it is an editor relationship or a viewer relationship.

A: Single joining table(books_users) is the best way for doing this with permission column in it. Lets say integer column with 1 for view 2 for edit(3 for both if it could be a possibilty). And to get editor or viewer users you should write scope in their joining model(BooksUsers)
scope :viewers, -> { where(permission: 1) }
scope :editors, -> { where(permission: 2) }

now you can find books particular user from these scope
Book.find(1).books_users.viewers
Book.find(1).books_users.editors


text:
Q: Writing procedures for multi-tenant database, schema as variable I am designing a multi-tenant database. Many actions that are needed on a per-tenant basis have been written as stored procedures. Almost all of them use dynamic SQL execution since I have not found a way to differentiate between the schemas other than with dynamic statements.
EXEC( 'SELECT * FROM ' + @SchemaName + '.Contacts' )

Is there any way to create a variable representing the schema so I can call the select statements without building them dynamically?
SELECT * FROM @TheSchema.Contacts

SQL Server 2008

A: FWIW I have found it much more useful to separate customers by database than by schema. Reasons?

*

*All schemas can have identical procedures, thus derive them from model instead of having to create anything. Deployment to multiple databases is no more complex than deployment to multiple schemas, actually less so I'd argue, and the only difference is the application would have to know which database to reference instead of which schema.

*Different customers can have different recovery models, be backed up on different schedules, etc. This can improve your backup/restore plan especially as the data set gets larger.

*Having each customer in a separate database makes it very easy to move a tenant to a different server if they get too big for the current one. Extracting the data and objects for their schema only will be quite convoluted.

*Some customers may legally and/or contractually require that you not store their data in the same database as other customers.

A: A simpler solution is to keep the stored procedure in each of the tenant databases and execute it inside them.

A: This question is a bit old, but I am looking into this option as a cost savings measure - since many cloud providers charge per database and the costs associated with storage are less - especially useful for multi-tenant small databases.
From what I understand, a default schema can be set for the login, thus, setting a schema per login would automatically use that schema for all queries and sprocs. Something to consider for those that comes across this question.


text:
Q: Apex Collection: how to have actual column names instead of C001, C002 created a page to allow users to input SQL statement, when user press button, it should Execute this query and another region with Classic Report will display results.
on Button a Dynamic Action execute PL/SQL code below:
on Click event:
begin
IF :P8_YOURSQL IS NOT NULL THEN
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
p_collection_name => 'SOMECOLLECTION',
p_query => :P8_YOURSQL,
p_truncate_if_exists => 'YES'
);
end if;
end;

Item to Submit: P8_YOURSQL
second Action refreshes CR region and CR region is based on:
SELECT * FROM APEX_COLLECTIONS
WHERE COLLECTION_NAME = 'SOMECOLLECTION';

resulted columns are not limited to the query results and column headers are C001, C002, C003 etc.
(a) how i can limit the columns to the SQL statement contained?
(b) how to change header to the actual column names?
(c) how to check for a valid SQL statement?
please help with sample code How To.

A: APEX_COLLECTIONS is a generic table so it has a couple of columns for the most common data types with names like C001, N001 etc. As with any table columns can be aliased in a query.
Example:

*

*Create page process before header to populate the collection

APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
  p_collection_name => 'EMP_COLLECTION',
  p_query => q'!SELECT * FROM emp!',
  p_truncate_if_exists => 'YES'
);

*

*Run the page and open the "Session" window from the developer toolbar. Select "Collections" in the "View" dropdown and click "Set". This will list the data in the APEX_COLLECTIONS table for any collections that exist for the session. Take note of the data and the columns the data is in.

*Leave the "Sessions" window open and create a sql query on the APEX_COLLECTIONS view with appropriate aliases.
SELECT
  c001 as EMPNO,
  c002 as ENAME,
  c003 as JOB,
  c004 as MGR,
  <rest_of_columns>...
 FROM
  APEX_COLLECTIONS WHERE collection_name = 'EMP_COLLECTION'

It's not possible to alias columns when doing a SELECT * FROM ...
If the SELECT *  is important then there is another possibility. Create a view on top of APEX_COLLECTIONS with relevant column names. Example:
CREATE OR REPLACE view EMP_COLLECTION_V
AS
SELECT
  c001 as EMPNO,
  c002 as ENAME,
  c003 as JOB,
  c004 as MGR
 FROM
  APEX_COLLECTIONS WHERE collection_name = 'EMP_COLLECTION'

and then use SELECT * FROM EMP_COLLECTION_V as SQL source for the classic report.

A: To get the columns names for a SELECT * FROM ... have a look at [DBMS_SQL.DESCRIBE_COLUMNS3][https://docs.oracle.com/en/database/oracle/oracle-database/18/arpls/DBMS_SQL.html#GUID-00AB5DE3-C428-4E60-9398-FD4892F32402]. There is an example in the doc that shows how to print the column names.
This can then be implemented in a classic report

*

*Create a page item per column: P1_C1, P1_C2, etc

*Set the column header for each column to the corresponding page item: col1 has header &P1_C1, col2 has header &P1_C2, etc

*Create a page process to set the column headers based on the sql query using DBMS_SQL.DESCRIBE_COLUMNS3 - OR - use a

Note that it is strongly advised to assert the sql query to avoid unwanted sql (like a delete or drop table command).


text:
Q: Weird now() time difference with Postgres triggers In a Postgres 10.10 database, I have a table table1 , and an AFTER INSERT trigger on table1 for table2:
CREATE TABLE table1 (
    id SERIAL PRIMARY KEY,
    -- other cols
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE UNIQUE INDEX table1_pkey ON table1(id int4_ops);

CREATE TABLE table2 (
    id SERIAL PRIMARY KEY,
    table1_id integer NOT NULL REFERENCES table1(id) ON UPDATE CASCADE,
    -- other cols (not used in query)
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE UNIQUE INDEX table2_pkey ON table2(id int4_ops);

This query is executed on application start:
CREATE OR REPLACE FUNCTION after_insert_table1()
RETURNS trigger AS
$$
BEGIN
    INSERT INTO table2 (table1_id, ..., created_at, updated_at)
    VALUES (NEW.id, ..., 'now', 'now');
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';

DROP TRIGGER IF EXISTS after_insert_table1 ON "table1";

CREATE TRIGGER after_insert_table1
AFTER INSERT ON "table1"
FOR EACH ROW
EXECUTE PROCEDURE after_insert_table1();

I noticed some created_at and updated_at values on table2 are different to table1. In fact, table2 has mostly older values.
Here are 10 sequential entries, which show the difference jumping around a huge amount within a few minutes:
|table1_id|table1_created            |table2_created               |diff            |
|---------|--------------------------|-----------------------------|----------------|
|2000     |2019-11-07 22:29:47.245+00|2019-11-07 19:51:09.727021+00|-02:38:37.517979|
|2001     |2019-11-07 22:30:02.256+00|2019-11-07 13:18:29.45962+00 |-09:11:32.79638 |
|2002     |2019-11-07 22:30:43.021+00|2019-11-07 13:44:12.099577+00|-08:46:30.921423|
|2003     |2019-11-07 22:31:00.794+00|2019-11-07 19:51:09.727021+00|-02:39:51.066979|
|2004     |2019-11-07 22:31:11.315+00|2019-11-07 13:18:29.45962+00 |-09:12:41.85538 |
|2005     |2019-11-07 22:31:27.234+00|2019-11-07 13:44:12.099577+00|-08:47:15.134423|
|2006     |2019-11-07 22:31:47.436+00|2019-11-07 13:18:29.45962+00 |-09:13:17.97638 |
|2007     |2019-11-07 22:33:19.484+00|2019-11-07 17:22:48.129063+00|-05:10:31.354937|
|2008     |2019-11-07 22:33:51.607+00|2019-11-07 19:51:09.727021+00|-02:42:41.879979|
|2009     |2019-11-07 22:34:28.786+00|2019-11-07 13:18:29.45962+00 |-09:15:59.32638 |
|2010     |2019-11-07 22:36:50.242+00|2019-11-07 13:18:29.45962+00 |-09:18:20.78238 |

Sequential entries have similar differences (mostly negative/mostly positive), and similar orders of magnitude (mostly minutes vs mostly hours) within the sequence, though there are exceptions
Here are the top 5 largest positive differences:
|table1_id|table1_created            |table2_created               |diff            |
|---------|--------------------------|-----------------------------|----------------|
|1630     |2019-10-25 21:12:14.971+00|2019-10-26 00:52:09.376+00   |03:39:54.405    |
|950      |2019-09-16 12:36:07.185+00|2019-09-16 14:07:35.504+00   |01:31:28.319    |
|1677     |2019-10-26 22:19:12.087+00|2019-10-26 23:38:34.102+00   |01:19:22.015    |
|58       |2018-12-08 20:11:20.306+00|2018-12-08 21:06:42.246+00   |00:55:21.94     |
|171      |2018-12-17 22:24:57.691+00|2018-12-17 23:16:05.992+00   |00:51:08.301    |

Here are the top 5 largest negative differences:
|table1_id|table1_created            |table2_created               |diff            |
|---------|--------------------------|-----------------------------|----------------|
|1427     |2019-10-15 16:03:43.641+00|2019-10-14 17:59:41.57749+00 |-22:04:02.06351 |
|1426     |2019-10-15 13:26:07.314+00|2019-10-14 18:00:50.930513+00|-19:25:16.383487|
|1424     |2019-10-15 13:13:44.092+00|2019-10-14 18:00:50.930513+00|-19:12:53.161487|
|4416     |2020-01-11 00:15:03.751+00|2020-01-10 08:43:19.668399+00|-15:31:44.082601|
|4420     |2020-01-11 01:58:32.541+00|2020-01-10 11:04:19.288023+00|-14:54:13.252977|

Negative differences outnumber positive differences 10x. The database timezone is UTC.
table2.table1_id is a foreign key, so it should be impossible to insert before insert on table1 completes.
table1.created_at is set by Sequelize, using option timestamps: true on the model.
When a row is inserted into table1, it's done inside a transaction. From the documentation I can find, triggers are executed inside the same transaction, so I can't think of a reason for this.
I can fix the issue by changing my trigger to use NEW.created_at instead of 'now', but I'm curious if anyone has any idea what the cause of this bug is?
Here is the query used to produce the above difference tables:
SELECT
    table1.id AS table1_id,
    table1.created_at AS table1_created,
    table2.created_at AS table2_created,
    (table2.created_at - table1.created_at) AS diff
FROM table1
INNER JOIN table2   ON
    table2.table1_id = table1.id AND (
        (table2.created_at - table1.created_at) > '2 min' OR
        (table1.created_at - table2.created_at) > '2 min')
ORDER BY diff;

A: While 'now' is not a plain string, it is also not a function in this context, but a special date/time input. The manual:

... simply notational shorthands that will be converted to ordinary date/time values when read. (In particular, now and related strings are converted to a specific time value as soon as they are read.)

The body of a PL/pgSQL function is stored as string, each nested SQL command is parsed and prepared when control reaches it the first time per session. The manual:

The PL/pgSQL interpreter parses the function's source text and
  produces an internal binary instruction tree the first time the
  function is called (within each session). The instruction tree fully
  translates the PL/pgSQL statement structure, but individual SQL
  expressions and SQL commands used in the function are not translated
  immediately.
As each expression and SQL command is first executed in the function,
  the PL/pgSQL interpreter parses and analyzes the command to create a
  prepared statement, using the SPI manager's SPI_prepare function.
  Subsequent visits to that expression or command reuse the prepared statement.

There is more. Read on. But that's enough for our case:
The first time the trigger is executed per session, 'now' is translated to the current timestamp (the transaction timestamp). While doing more inserts in that same transaction, there won't be any difference to transaction_timestamp() because that is stable within a transaction by design.
But every subsequent transaction in the same session will insert the same, constant timestamp in table2, while values for table1 may be anything (not sure what Sequelize does there). If new values in table1 are the then current timestamp, that results in a "negative" diff in your test. (Timestamps in table2 will be older.)
Solution
Situations where you actually want 'now' are few and far between. Typically, you want the function now() (without single quotes!) - which is equivalent to CURRENT_TIMESTAMP (standard SQL) and transaction_timestamp(). Related (recommended reading!):

*

*Difference between now() and current_timestamp
In your particular case I suggest column defaults instead of doing additional work in triggers. If you set the same default now() in table1 and table2, you also eliminate any nonsense the INSERT to table1 might add. And you never have to even mention these columns in inserts any more:
CREATE TABLE table1 (
    id SERIAL PRIMARY KEY,
    -- other cols
    created_at timestamptz NOT NULL DEFAULT now(),
    updated_at timestamptz NOT NULL DEFAULT now()   -- or leave this one NULL?
);

CREATE TABLE table2 (
    id SERIAL PRIMARY KEY,
    table1_id integer NOT NULL REFERENCES table1(id) ON UPDATE CASCADE,
    -- other cols (not used in query)
    created_at timestamptz NOT NULL DEFAULT now(),  -- not 'now'!
    updated_at timestamptz NOT NULL DEFAULT now()   -- or leave this one NULL?
);

CREATE OR REPLACE FUNCTION after_insert_table1()
  RETURNS trigger LANGUAGE plpgsql AS
$$
BEGIN
   INSERT INTO table2 (table1_id)  -- more columns? but not: created_at, updated_at
   VALUES (NEW.id);                -- more columns?

   RETURN NULL;                     -- can be NULL for AFTER trigger
END
$$;


text:
Q: Shipping Option Name Missing from IPN What would cause the shipping option chosen by the customer (along with some related fields) to not be returned in the IPN?
We are using an encrypted 'cart upload' command combined with the Instant Update API to provide dynamic shipping options based on the customer's address (explained here ). In some (not all) cases, the shipping_option_name and some related values are not being returned in the IPN. Additionally, the name of the shipping option selected by the user is not available from the PayPal interface when we view transaction details.
Note that this happens in only some cases, and we cannot find a common cause among the failures.
UPDATE 1/29/14 - We have noticed that the shipping option name is being recorded for ALL transactions in which the Counterparty Status is "Unregistered," and about 25% of the transactions for which the Counterparty Status is something else (e.g., Confirmed, Non-Confirmed, Verified, etc.).
We have set up logging to track outgoing Instant Update data and incoming IPN data. In cases where the shipping_option_name is missing from the IPN, the following fields are also missing:

*

*Shipping_calculation_mode

*shipping_option_name

*insurance_option_selected

*shipping_option_amount

*insurance_amount

*receipt_id

*shipping_is_default

I'm pasting our Instant Update response and the PayPal IPN for two very similar transactions below. Both transactions purchase the same product, have the same shipping price, and the customers live in the same state. The first transaction successfully returned the shipping option name in the IPN and the second transaction did not. Sensitive values have been replaced with XX. Note the Instant Update response is identical between the two transactions, yet some values are missing from the IPN for the second transaction.
First Transaction - Successfully records shipping option name
------------
OUR INSTANT UPDATE RESPONSE
-----------
METHOD=CallbackResponse
&L_SHIPPINGOPTIONLABEL0=Ground
&L_SHIPPINGOPTIONAMOUNT0=16.95
&L_TAXAMT0=0
&L_SHIPPINGOPTIONISDEFAULT0=true
&L_SHIPPINGOPTIONLABEL1=3-Day
&L_SHIPPINGOPTIONAMOUNT1=45
&L_TAXAMT1=0
&L_SHIPPINGOPTIONISDEFAULT1=false
&L_SHIPPINGOPTIONLABEL2=2-Day
&L_SHIPPINGOPTIONAMOUNT2=60
&L_TAXAMT2=0
&L_SHIPPINGOPTIONISDEFAULT2=false
&L_SHIPPINGOPTIONLABEL3=Next Day - Standard (Afternoon)
&L_SHIPPINGOPTIONAMOUNT3=85
&L_TAXAMT3=0
&L_SHIPPINGOPTIONISDEFAULT3=false
&L_SHIPPINGOPTIONLABEL4=Next Day - Priority (Morning)
&L_SHIPPINGOPTIONAMOUNT4=100
&L_TAXAMT4=0
&L_SHIPPINGOPTIONISDEFAULT4=false

------------
IPN DATA FROM PAYPAL
-----------
[p] => store/paypal-checkout-response
[Shipping_calculation_mode] => Callback
[mc_gross] => 132.15
[protection_eligibility] => Eligible
[address_status] => confirmed
[item_number1] => 18827
[payer_id] => XX
[tax] => 0.00
[address_street] => XX
[payment_date] => 09:00:47 Jan 23, 2014 PST
[payment_status] => Completed
[charset] => windows-1252
[shipping_option_name] => Ground
[address_zip] => XX
[mc_shipping] => 16.95
[mc_handling] => 0.00
[first_name] => XX
[mc_fee] => 4.13
[address_country_code] => US
[address_name] => XX
[notify_version] => 3.7
[insurance_option_selected] => 0
[custom] => XX
[payer_status] => unverified
[business] => XX
[address_country] => United States
[shipping_option_amount] => 16.95
[num_cart_items] => 1
[mc_handling1] => 0.00
[address_city] => XX
[verify_sign] => XX
[payer_email] => XX
[mc_shipping1] => 0.00
[tax1] => 0.00
[txn_id] => XX
[payment_type] => instant
[last_name] => XX
[address_state] => MO
[item_name1] => End Caps
[receiver_email] => XX
[payment_fee] => 4.13
[quantity1] => 1
[insurance_amount] => 0.00
[receiver_id] => XX
[txn_type] => cart
[mc_gross_1] => 115.20
[mc_currency] => USD
[residence_country] => US
[receipt_id] => XX
[transaction_subject] => XX
[payment_gross] => 132.15
[shipping_is_default] => 1
[ipn_track_id] => XX

Second transaction - Shipping option name was not recorded or returned by IPN
------------
OUR INSTANT UPDATE RESPONSE
-----------
METHOD=CallbackResponse
&L_SHIPPINGOPTIONLABEL0=Ground
&L_SHIPPINGOPTIONAMOUNT0=16.95
&L_TAXAMT0=0
&L_SHIPPINGOPTIONISDEFAULT0=true
&L_SHIPPINGOPTIONLABEL1=3-Day
&L_SHIPPINGOPTIONAMOUNT1=45
&L_TAXAMT1=0
&L_SHIPPINGOPTIONISDEFAULT1=false
&L_SHIPPINGOPTIONLABEL2=2-Day
&L_SHIPPINGOPTIONAMOUNT2=60
&L_TAXAMT2=0
&L_SHIPPINGOPTIONISDEFAULT2=false
&L_SHIPPINGOPTIONLABEL3=Next Day - Standard (Afternoon)
&L_SHIPPINGOPTIONAMOUNT3=85
&L_TAXAMT3=0
&L_SHIPPINGOPTIONISDEFAULT3=false
&L_SHIPPINGOPTIONLABEL4=Next Day - Priority (Morning)
&L_SHIPPINGOPTIONAMOUNT4=100
&L_TAXAMT4=0
&L_SHIPPINGOPTIONISDEFAULT4=false

------------
IPN DATA FROM PAYPAL
-----------

[p] => store/paypal-checkout-response
[mc_gross] => 132.15
[protection_eligibility] => Eligible
[address_status] => confirmed
[item_number1] => 18827
[payer_id] => XX
[tax] => 0.00
[address_street] => XX
[payment_date] => 07:11:37 Jan 23, 2014 PST
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => XX
[mc_shipping] => 16.95
[mc_handling] => 0.00
[first_name] => XX
[mc_fee] => 4.13
[address_country_code] => US
[address_name] => XX
[notify_version] => 3.7
[custom] => XX
[payer_status] => verified
[business] => XX
[address_country] => United States
[num_cart_items] => 1
[mc_handling1] => 0.00
[address_city] => XX
[verify_sign] => XX
[payer_email] => XX
[mc_shipping1] => 0.00
[tax1] => 0.00
[txn_id] => XX
[payment_type] => instant
[last_name] => XX
[address_state] => MO
[item_name1] => End Caps
[receiver_email] => XX
[payment_fee] => 4.13
[quantity1] => 1
[receiver_id] => XX
[txn_type] => cart
[mc_gross_1] => 115.20
[mc_currency] => USD
[residence_country] => US
[transaction_subject] => XX
[payment_gross] => 132.15
[ipn_track_id] => XX

Any help would be greatly appreciated!

A: It all comes down to the DoExpressCheckoutPayment requestion.  You need to make sure to pass all the details about the shipping and address in this final call or it won't get included in the transaction details which means it won't be available in IPN.


text:
Q: GetUserNameW as wstring I would like to know how to get the currenty logged on user's name as a wstring.
I only found LPWSTR examples like that:
#include <iostream>
#include <windows.h>
#include <Lmcons.h>
using namespace std;

int main()

{
    wchar_t name[UNLEN+1];
    DWORD size = UNLEN + 1;

    if (GetUserNameW( (LPWSTR)name, &size ))
    {
        cout << "Hello, " << name << "!\n";
    }
    else
    {
        cout << "Hello, unnamed person!\n";
    }
}
return 0;

}
Can anybody tell me how to convert this to a wstring?
Thank you.

A: You can just use the constructor for std::wstring on the value in name after calling GetUserNameW:
if(GetUserNameW(name, &len))
{
    std::wstring strname(name);
    std::wcout << L"Hello, " << strname << std::endl;
}

If you're asking in general about why the Windows API doesn't support C++'s std:: stuff out of the box, it's because it's designed to be compatibile with C first and foremost.


text:
Q: Adapt fatFS library to PIC32 I'm developing an application with PIC32MX, that record 3 WAV sounds and store theme into SD. Unfortunately the speed that I have reach is 155 kB/s and is insufficient for my application. Then I have to move fatFS, that use multi sector write speed wich seems to solve my problem. I download the latest library for fatFS here (bottom of the page). I read on the internet that this code is generic and only some part of code needs to be adapted, based on microcontroller in use.
I have spent many time trying to understand what are this portions of code, but I still dont'find theme.
Anyone can help me?
EDIT: Finally I understand how to modify the fatFS for adapt it to my system.
But I have a little poblem. After I properly modified the "platform dependent" section with correct SPI and chip select pin, I tryied to compile. I obtained an error about windows.h and tchar.h, included in file integer.h. But in integer.h I see the ifdef, and I want compile the "embedded" section, not the windows section. If I try to delete the ifdef, I obtained this error: " ';' expected but 'fs_type' found ". This come from typedef struct of ff.h.
On internet there are project with the identical structure, why this doesn't compile?

A: Microchip Harmony and MLA both contain good fast file access libraries, supporting multiple backing stores including SD, MMC, CF-II, USB MSD, etc.  I suggest you give them a go since they are already tailored to the PIC32 chips.


text:
Q: Unresolved reference for Dagger 2 in Kotlin I am trying to use a Dagger 2 in my Android project where I code in Kotlin. I took an example from Dagger 2 repo android-simple. I have managed to properly configure the project in Android Studio using an example from dagger-android-gradle-sample, it contains properly configured gradle files.
Now I started changing java classes to kotlin. This is how auto-converted DemoApplication.java looks like in kotlin:
public class DemoApplication : Application() {

    Singleton
    Component(modules = array(javaClass<AndroidModule>()))
    trait ApplicationComponent {
        public fun inject(application: DemoApplication)
        public fun inject(homeActivity: HomeActivity)
        public fun inject(demoActivity: DemoActivity)
    }

    public var component: ApplicationComponent? = null

    override fun onCreate() {
        super.onCreate()
        component = `Dagger_DemoApplication$ApplicationComponent`.builder().androidModule(AndroidModule(this)).build()
        component!!.inject(this)
    }
}

Dagger generated classes are visible in Kotlin but it complains about ($) sign used in the class name. ($) in Kotlin has special purpose so I guess that's why. You can note that auto-convertion wrapped the class name with (`) sign so editor does not complains about it. Unfortunately, compiler is failing with:
Error:(32, 21) Unresolved reference: `Dagger_DemoApplication$ApplicationComponent`

:app:compileDebugKotlin FAILED

There is also an exception if I try to build it from Terminal:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.compile(Tasks.kt:130)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 47 more

Does anyone know how to solve this problem? If not I will have to keep classes using Dagger_* in java.

A: You can solve it by waiting! See https://github.com/google/dagger/issues/58.
The $ symbol is being removed from all of the generated code before the first release (and hopefully sooner rather than later).
Additionally, I would file a bug with Jetbrains about the behavior since $ is a perfectly valid character to appear in a class name.


text:
Q: Fatal error: Call to undefined function tep_session_name() I am trying to update one of the sites I maintain to the latest PHP and during this, I have come across the following error:

Fatal error: Call to undefined function tep_session_name() in ... /includes/application_top.php on line 83

The code it is referring to is:
 // set the session name and save path
 tep_session_name('osCAdminID');
 tep_session_save_path(SESSION_WRITE_DIRECTORY);

But I have looked at the sessions.php file are the function is defined in the below code:
 function tep_session_name($name = '') {
    if ($name != '') {
      return session_name($name);
    } else {
      return session_name();
    }
  }

Any help in identifying the cause would be greatly appreciated.
Thanks, E.

A: I'm absolutely sure, that you call this function before you include file with function declaration


text:
Q: Group by functionality in Java I am trying to write a Java program that loads the data (from a tab delimited DAT file) and determines the average amount in Euros (EUR), grouped by Country and Credit Rating.
I have 2 questions,

*

*what is the best way to load the data into data structure after spliting into array?

*How do i approach about providing group by functionality in Java

Update: I have given a first try and this is how implementation looks like. Feels like there is a room for improvement.
    /**
 * @param rows - Each row as a bean
 * This method will group objects together based on Country/City and Credit Rating
 */
static void groupObjectsTogether(List<CompanyData> rows) {
    Map<String, List<CompanyData>> map = new HashMap<String, List<CompanyData>>();

    for(CompanyData companyData : rows){
        String key;

        if(companyData.getCountry().trim().equalsIgnoreCase("") || companyData.getCountry() == null){
            key = companyData.getCity()+":"+companyData.getCreditRating();          //use city+creditRating as key
        }else{
            key = companyData.getCountry()+":"+companyData.getCreditRating();       //use country+creditRating as key
        }

        if(map.get(key) == null){
            map.put(key, new ArrayList<CompanyData>());
        }
        map.get(key).add(companyData);
    }

    processGroupedRowsAndPrint(map);
}

A: It all depends on the amount of data and performance (CPU vs memory) of the machine. It the amount of data is not significant (less than millions of records or columns) and the number of columns is fixed then you may simply put all data in arrays using
String[] row = String.split(";");

which shall split each row using ; as delimiter. Then you may achieve your grouping functionality using HashMap, i.e.:
ArrayList<String[]> rowAr = new ArrayList<String[]>();
HashMap<String,ArrayList<Integer>> map = new HashMap<String,ArrayList<Integer>>();
int index = 0;
for (String rowStr: rows) {
    String[] row = rowStr.split(";");
    rowAr.add(row);
    String companyCode = row[0];
    //please keep in mind that for simplicity of the example I avoided
    //creation of new array if it does not exist in HashMap
    ((ArrayList<Integer>)map.get(companyCode)).add(index);
    index++;
}

Sorry for any syntax or other simple errors above (I do not have any tools in hand to verify if there is not any stupid mistake).


text:
Q: Clone a transform stream in NodeJS I'm trying to reuse a couple of transform streams (gulp-like, ie. concat() or uglify()) across several readable streams. I only have access to the created instances and not the original subclasses.
It does not work out of the box, I get Error: stream.push() after EOF when I pipe at lease two distinct readable streams into my transforms. Somehow the events do appear to leak from one stream to the other.
I've tried to setup a cloneTransform function to somehow cleanly "fork" into two distincts transforms, however I can't get it to not share events:
function cloneTransform(transform) {
    var ts = new Transform({objectMode: true});
    ts._transform = transform._transform.bind(ts);
    if(typeof transform._flush !== 'undefined') {
      ts._flush = transform._flush.bind(ts);
    }
    return ts;
  }

Any alternative idea, existing plugin or solution to address this?

Update: context
I'm working on a rewrite of the gulp-usemin package, it is hosted here: gulp-usemin-stream, example use here.
Basically you parse an index.html looking for comment blocks surrounding styles/scripts declarations, and you want to apply several configurable transformation to theses files (see grunt-usemin).
So the problem I'm trying to solve is to reuse an array of transforms, [concat(), uglify()] that are passed as options to a gulp meta transform.

A: you're doing unnecessary work in your code. it should be as simple as:
function clone(transform) {
  var ts = new Transform({ objectMode: true})
  ts._transform = transform._transform
  ts._flush = transform._flush
  return ts
}

however, i'm not sure how you're trying to use it, so i'm not sure what error you're getting. there's also the issue of initialization where the initial transform stream might initialize the stream with .queue = [] or something, and you won't be initializing it in your clone.
the solution completely depends on the problem you're trying to solve, and i feel like you're approaching the problem incorrectly in the first place.

A: It looks like you're trying to use a Transform stream directly instead of subclassing it. What you should be doing is subclassing Transform and overriding the _tranform and, optionally, _flush methods. That way, you can just create a new instance of your transform stream for each readable stream that you need to use it with.
Example:
var util = require('util');
var Transform = require('stream').Transform;

function MyTransform(options) {
    Transform.call(this, options);
    // ... any setup you want to do ...
}
util.inherits(MyTransform, Transform);

MyTransform.protocol._transform = function(chunk, encoding, done) {
    // ... your _transform implementation ...
}

// Optional
MyTransform.protocol._flush = function(done) {
    // ... optional flush implementation ...
}

Once you have that setup, you can simply create new instances of MyTransform for each stream you want to use it with:
var readStream1 = ...
var readStream2 = ...

var transform1 = new MyTransform();
var transform2 = new MyTransform();

readStream1.pipe(transform1).pipe(...);
readStream2.pipe(transform2).pipe(...);


text:
Q: td align right not working in html code I have a form and I want the labels to be aligned to the right. When I say "labels", I mean the text to the left of the form input boxes.  I have those in separate  elements.  When I type  it is not working. What do I have to change?
Full Html code:

LifeLink PSU Mentor Application
Please fill out all requried fields

  <form id="Mentorinfo">

        PSU ID:

          <input type="number" name="PSUID" />

        First Name:

          <input type="text" name="FirstName" />

        Last Name:

          <input type="text" name="LastName" />

        Age:

          <input type="number" name="Age">

        Phone number:

***-***-****

          <input type="text" name="MenTel" pattern=".*^[2-9]\d{2}-\d{3}-\d{4}$.*" />

        PSU email:

Example qwe1234@psu.edu

          <input type="text" name="Email" pattern=".*^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$.*" />

        Semester and year applying for?:

Example: Spring 2015

          <input type="text" name="SemYear" />

        Major(s):

separate majors with commas

          <input type="text" name="Major" />

        Which college are you from?:

          <input type="text" name="CollegeName" />

        Do you want to become a mentor or intern?:

          <input type="radio" name="VolType" value="mentor" />Mentor

          <input type="radio" name="VolType" value="intern" />Intern

        Are you doing this for major requirements or class credit?:

          <input type="radio" name="ForMentoring" value="Major requirement" />Major requirements

          <input type="radio" name="ForMentoring" value="Class credit" />Class credit

          <input type="radio" name="ForMentoring" value="Neither, just want to help out" />Neither, just want to help out!

        If for class credit, what class it for?

          <input type="text" name="ClassTitle" />

        How many hours are you required to complete?

          <input type="text" name="RequiredHours" />

        Your organization name (if applicable)

          <input type="text" name="Org" />

        If from an organization, how many hours are required?

(if applicable)

          <input type="text" name="OrgReqHrs" />

        What skills or experiences can you bring?

          <textarea name="Skills" cols="50" rows="10"></textarea>

        What extra-curricular activites are you involved in?

          <textarea name="ExtraCurricular" cols="50" rows="10"></textarea>

        Any additional information you would like share with us?

          <textarea name="AddDetails" cols="50" rows="10"></textarea>

Mentor/Volunteer Agreement

I agree not to dispense any medication (Tylenol, etc) to students

I agree to be responsible about attending. If I cannot fulfill my obligation, i will call in a timely manner.

I agree to avoid activities/places prohibited by the program or in the student's individual permission form. (e.g going to fraternities/sororities, dorm rooms, etc)

I agree to maintain language, attire, conduct, etc., appropriate for working with high school students.

I agree to adhere to professional guidelines regarding confidentiality.

I agree to embrace the spirit and philosophy of the program, e.g developing independence, social relationships, etc.

            <input type="checkbox" name="Agreement" value="1">I Aggree to the above terms of mentorship.

      <input type="button" value="Submit" class="button medium-btn" onclick="google.script.run
                                         .withSuccessHandler(Success)
                                         .withFailureHandler(Failed)
                                         .processForm(document.forms[0]);" />

      <input float="center" type="button" value="Clear" class="button medium-btn" onclick="clear()" />

  </form>

A: remove the css property text-align:left from
 td {
      padding: 5px;
      text-align: left;
    }

like this
td {
      padding: 5px;
    }

and add individually foreach td
WORKING DEMO


text:
Q: Add & delete note in AngularJS I am new at AngularJS and I am trying to figure out how to add and delete notes to the setup that I have created. I have tried a lot of different things but I cant figure out how to get it to work.
I have cleaned up my code so it should be easier to figure out.
Please take a look at the jsfiddle version or snippet of my code:

'use strict'

var app = angular.module('plunker', ['ui.sortable']);

app.controller('MainCtrl', function($scope) {

  var i;
  $scope.itemsList = {
    items1: [],
    items2: []
  };

  for (i = 0; i <= 5; i += 1) {
    $scope.itemsList.items1.push({
      'Id': i,
      'Label': 'Item ' + i
    });
  }
  $scope.sortableOptions = {
    containment: '#sortable-container',
    accept: function(sourceItemHandleScope, destSortableScope) {
      return sourceItemHandleScope.itemScope.sortableScope.$id === destSortableScope.$id;
    }
  };

});
.as-sortable-item,
.as-sortable-placeholder {} #sortable-container {} .touch-mover {
  float: right;
  padding: 3px;
  margin-top: 5px;
}

        <form>
          <input class="span3" size="16" type="text" placeholder="Add a note">
          <button class="btn btn-success" type="button" ng-disabled="" ng-click="">
            Add Note
          </button>
        </form>

        <input class="category-form textboxid" type="text" name="input" ng-model="item.Label" placeholder="Deltager1">

MOVE ME

DELETE

        <input class="category-form textboxid" style="float:right" type="text" name="input" ng-model="item.Label2" placeholder="Deltager2">

A: For adding a note just insert into your controller MainCtrl this function:
$scope.addNote = function() {
    $scope.itemsList.items1.push({"Id" :  $scope.itemsList.items1.length, "Label": "Item " + $scope.itemsList.items1.length})
}

and edit your form (add ng-model to input and ng-click function to button) like:
<input class="span3" size="16" type="text" ng-model="noteText" placeholder="Add a note">
<button class="btn btn-success" type="button" ng-disabled="" ng-click="addNote()">
   Add Note
</button>

For deleting use in you controller something like
$scope.deleteNote = function(index) {
    $scope.itemsList.items1.splice(index,1)
}

and attach this function to the  tag "DELETE" like
ng-click="deleteNote($index)"

I hope this helps.


text:
Q: possible solutions for the given equation Given X,p,a,b. We need to find out how many positive integers n ( 1 <= n <= X) satisfies the following condition:-
na^n ≡ b(mod p)

Constraints:
2 <= p <= 10^6,
1 <= a,b< p,
1 <= X <= 10^12

I have no idea how to solve this question, any approach or proof will be highly helpful.
Thanks.

A: This assumes p is prime.
For each i from 1 upwards, compute a^i. At some point (call it q), you'll get to 1 and then you can stop. Then finding all n <= X such that na^n = b (mod p) and a^n = a^i (mod p) is a question of counting all solutions to n = b*(a^i)^-1 (mod p) and n=i (mod q), which you can do using the Chinese remainder theorem.
This process enumerates all solutions exactly once, and if you're careful runs in O(p) time. (The care is needed to avoid O(p log p) if you calculate a^i (mod p) and (a^i)^-1 (mod p) from scratch each iteration).


text:
Q: best way to transfer data from one database to other in ms sql express 05 using c# I have old sql express 05 database where some tables contains important data that is want to transfer to new sql express 05 database.
I want to preserve auto ids of old data in tables, but dont want to transfer all tables only some tables i want to transfer, but problem is I have to achieve this using c# 3.5 winform app
My tasks are:

*

*create new blank database

*transfer some old tables to new database

*create other tables in new database

Anybody have good approch to acchive it using c#,stored procedurs etc.

A: use winform to launch an SSIS package programmatically.
http://msdn.microsoft.com/en-us/library/ms136090.aspx
you'll have to buy (or msdn download perhaps?) sql developer edition to get integration services (SSIS)

A: Check if SQL express accepts this command: set identity sales on, or similar; this will allow you to insert the data from the old table(s) to the new table and keeping your existing identity values in the new tables.
I would use a store procedure to do the data transfer work. You can call/execute the procedure from your C# winform app.
Before inserting the data, set the identity option on for each table you want to transfer data.
The command to transfer data for each table can be something like:
Set identity newtable on
insert into newtable (identitycolum, column1, column2, column3)
Select identitycolum, column1, column2, column3
From oldtable
Set identity newtable off
Hope that helps.


text:
Q: OnBootReceiver works, but doesn't find AlarmReceiver I'm trying to set up an alarm receiver right after booting. Therefore, i have an OnBootReceiver that should register the alarm. The onBootReceiver works and it gets called, but somehow it cannot find my AlarmReceiver class.
OnBootReceiver which succesfully starts after booting:
public class OnBootReceiver extends BroadcastReceiver {

    private static final String TAG = "OnBootReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "called");

        Intent i = new Intent(context, com.packagenames.AlarmReceiver.class);
        PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

        Calendar time = Calendar.getInstance();
        time.setTimeInMillis(System.currentTimeMillis());
        time.add(Calendar.SECOND, 30);

        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), time.getTimeInMillis(), pi);

    }

}

As you you can see, it configures the alarm tries to invoke com.packagenames.AlarmReceiver.class. This class exists and is located in the same package:
public class AlarmReceiver extends BroadcastReceiver {

    private static final String TAG = "AlarmReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "alarm received");
        Intent i = new Intent(context, com.packagename.DataService.class);
        i.putExtra("action", "process");
        context.startService(i);
    }

}

Unfortunately, i get the following error:

02-03 09:22:25.344: W/ActivityManager(103): Unable to start service
  Intent { flg=0x4 cmp=com.phonegap.packagename/.AlarmReceiver (has extras)
  }: not found

The Android Manifest looks like this
<application>

// activities etc

        <receiver
            android:name="com.phonegap.packagename.OnBootReceiver"
            android:enabled="true"
            android:exported="false"
            android:label="OnBootReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="com.phonegap.packagename.AlarmReceiver"
            android:enabled="true"
            android:label="AlarmReceiver">
            <intent-filter>
            </intent-filter>
        </receiver>

    </application>

Do you see a mistake? Maybe I forgot something?
Thanks
edit: in the manifest, I added
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

in order to make the OnBootReceiver work. Do I need something similar for the alarm?

A: Shouldn't you use getBroadcast instead of getService when creating a pending intent ?

A: The whole receiver stuff ONLY works if you application is NOT installed on a SD card. Add this to your manifest file to do so:
android:installLocation="internalOnly"


text:
Q: Wordpress "Featured image" stopped working on custom php page (V 3.8.1) I have a strange problem which I'm hoping is just due to me missing something obvious...
Our Wordpress installation has upgraded to 3.8.1 recently. We use WordPress within a directory on the site as part of our news items. We loop through posts in other sections of our site to show latest news etc
We have featured image enabled, and have the featured images showing on the wordpress/news home page by using the following code:
<a href="<?php the_permalink() ?>">
<?php the_post_thumbnail('thumbnail'); ?>

This works fine, and outputs the 150px by 150px featured image.
We also wish to show the featured image next to the posts we loop through on the other pages of the site, but we can't seem to get it working.
This is the code:
foreach($posts as $post) {
setup_postdata($post);
if ( has_post_thumbnail() ) {
echo "";
the_post_thumbnail(array('50','50'));
echo "";
}
echo "
";
echo the_title();
echo "
\n
";
$string = strip_tags(strip_shortcodes($post->post_content));
echo chop_string($string,190,'...');
echo " ";
echo "Read More
\n";
echo "

\n";
}

The post var is declared a bit higher up the script:
$posts = get_posts('numberposts=8&orderby=date');

Everything except the image is outputted, even the link around where the image should be is outputted, indicating that the has_post_thumbnail() func has returned true. As I said, it's also working on the wordpress page itself.
I have tried with 'thumbnail' passed instead of the size array, and also get_the_post_thumbnail(), and I'm at a loss as to why it's not working!
Any help would be great
Thanks

A: USe this one using get function.
<?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>

    get_the_post_thumbnail($post_id);                  // without parameter -> Thumbnail

    get_the_post_thumbnail($post_id, 'thumbnail');     // Thumbnail
    get_the_post_thumbnail($post_id, 'medium');        // Medium resolution
    get_the_post_thumbnail($post_id, 'large');         // Large resolution
    get_the_post_thumbnail($post_id, 'full');          // Original resolution

    get_the_post_thumbnail($post_id, array(100,100) ); // Other resolutions

In your Custom Post Type, do you setup_postdata( $post )
 in your custom Loop? If not, has_post_thumbnail()
might not be defined/available?
EDIT:

Try adding:

setup_postdata( $post );

Right before:

$loop->the_post();

And then see if has_post_thumbnail() returns true?

Or, try passing the $post->ID to your call to has_post_thumbnail()?

has_post_thumbnail( $post->ID );

A: Try  changing
the_post_thumbnail(array('50','50'));

to
echo get_the_thumbnail($post->ID, array(50,50));


text:
Q: Can repetitive WHERE clauses within a UNION query be consolidated? I have a number of distinct tables in SQL that share the same schema, but contain different data. I was writing a query that utilizes a consistent WHERE clause on each of the tables and then UNIONs them all together. After writing a few of these I realize that copying the same WHERE clause again and again started to look very redundant, and I'm wondering if there's some way I can rewrite this query that doesn't repeat things so much. Here's a pared down version of the query I'm using:
SELECT a.primary_key, a.field1, b.field1 AS field2, 'One' AS source
FROM table_1 a JOIN table_1_meta b ON a.primary_key = b.primary_key
WHERE a.address_line_1 = '1234 Fake St' AND a.city = 'Beverly Hills' AND a.zip = '90210'
UNION ALL
SELECT a.primary_key, a.field1, b.field1 AS field2, 'Two' AS source
FROM table_2 a JOIN table_2_meta b ON a.primary_key = b.primary_key
WHERE a.address_line_1 = '1234 Fake St' AND a.city = 'Beverly Hills' AND a.zip = '90210'
UNION ALL
SELECT a.primary_key, a.field1, b.field1 AS field2, 'Three' AS source
FROM table_3 a JOIN table_3_meta b ON a.primary_key = b.primary_key
WHERE a.address_line_1 = '1234 Fake St' AND a.city = 'Beverly Hills' AND a.zip = '90210'
UNION ALL
SELECT a.primary_key, a.field1, b.field1 AS field2, 'Four' AS source
FROM table_4 a JOIN table_4_meta b ON a.primary_key = b.primary_key
WHERE a.address_line_1 = '1234 Fake St' AND a.city = 'Beverly Hills' AND a.zip = '90210'

Please refrain from any kinds of answers suggesting that I restructure the data/tables themselves, and suffice it to say that that is not an option in this situation. I am interested in learning whether this specific query can be refactored to consolidate the identical WHERE clauses.

A: As mentioned in a comment above, you can union several queries without WHERE clauses, and then treat that as a derived table to which you apply the WHERE clause a single time.
Here how it would look:
SELECT t.primary_key, t.field1, t.field2, t.source FROM (
  SELECT a.primary_key, a.field1, b.field1 AS field2, 'One' AS source, a.address_line_1, a.city, a.zip
  FROM table_1 a JOIN table_1_meta b ON a.primary_key = b.primary_key
  UNION ALL
  SELECT a.primary_key, a.field1, b.field1 AS field2, 'Two' AS source, a.address_line_1, a.city, a.zip
  FROM table_2 a JOIN table_2_meta b ON a.primary_key = b.primary_key
  UNION ALL
  SELECT a.primary_key, a.field1, b.field1 AS field2, 'Three' AS source, a.address_line_1, a.city, a.zip
  FROM table_3 a JOIN table_3_meta b ON a.primary_key = b.primary_key
  UNION ALL
  SELECT a.primary_key, a.field1, b.field1 AS field2, 'Four' AS source, a.address_line_1, a.city, a.zip
  FROM table_4 a JOIN table_4_meta b ON a.primary_key = b.primary_key
) AS t
WHERE t.address_line_1 = '1234 Fake St' AND t.city = 'Beverly Hills' AND t.zip = '90210'

You may notice that each of the unioned queries must expose the columns address_line_1, city, zip so that they are available in the derived table. Otherwise the WHERE conditions in the outer query would not be able to reference them. They must be columns of the derived table. But you don't have to include those extra columns in the select-list of the outer query.
So ultimately it doesn't look like a lot of savings in typing.
One possible downside of this is that the derived table might have millions and millions of rows and builds an enormous temporary table to hold them, only to have them mostly filtered out by the conditions in the WHERE clause of the outer query.
There is no guarantee that your SQL engine is clever enough to propagate the condition to each of the unioned queries that comprise the derived table. This may be implemented in some implementations of SQL that you use.
But you only tagged your question with sql. That tag is used on Stack Overflow for the SQL language generally, not any specific brand or product that implements SQL.


text:
Q: Colonel Blotto Game variation Here are 10 castles, numbered 1, 2, 3, ..., 10, and worth 1, 2, 3, ..., 10 points respectively. You have 100 soldiers, which you can allocate between the castles however you wish. Your opponent also (independently) does the same. The number of soldiers on each castle is then compared, and for each castle, whoever has the most soldiers on that castle wins its points. Additionally, you lose 0.2 points for each "extra" soldier that you have, in excess of your opponent's army size, at each castle that you win. You still need to deploy all 100 soldiers. In the case of a tie, no one gets points for that castle.
I am not sure how to account for the 0.2 points for deploying an extra soldier.


text:
Q: Vim Solarized dark theme looks weird on iTerm2 I just installed the solarized colorscheme following instructions on the project's page.
This is what it looks like now:

which is not like those screenshots on the official page.
Any idea how to fix this?
EDIT:
This is the color setup of my iterm2 profile.

Problame Solved
Find the answer in Solarized background colour off in emacs under tmux

A: You have two options, the first is to add the following line to your .vimrc to use a slightly degraded version of the colorscheme:
let g:solarized_termcolors=256

Or you can install the the color palette iterm2-colors-solarized/Solarized Dark.itermcolors from the following download off of the author's website.
Source: Solarized Readme, "IMPORTANT NOTE FOR TERMINAL USERS" section.

A: I had this exact issue and the following worked for me:

In iTerm2, in Preferences -> Profiles -> Terminal, under "Terminal Emulation" you have "Report Terminal Type:" set to xterm-256color.

Mine was set to just xterm and resulted in the funky coloring. Hope this helps.
edit: via https://stackoverflow.com/questions/7278267/incorrect-colors-with-vim-in-iterm2-using-solarized

A: I had found this same problem.  Many people are stuck with 256-term color translation issues.  However, I found that the 'washed out' look remains even when it is configured correctly.
I suspect this is because of the choice of colors.  I respect Ethan's work, but I don't find them high-contrast enough, even after calibrating my monitor.  (if someone could show me a more-correct way to think about it, I welcome that)
My solution was to modify the color definition files.  You can find my modifications here in m fork.

A: I imported solarized themes into iTerm2. The color looks weird. But it sometimes works.
After some tests, I finally find out that it works only if I start iTerm2 with
light solarized theme. Once it works the dark theme works too if I change from
the light one to the dark one!
I get color themes from
https://github.com/mbadolato/iTerm2-Color-Schemes
And I find that Solarized Dark Higher Contrast.itermcolors works fine If I start
iterm2 with it.
I think theme files that work may have some key differences. eg. high contract or
something. And the difference only take effect on new started iTerm2.


text:
Q: Referencing nodes in matrix of nodes does not work in beamer When using node coordinates in a matrix of nodes in the article document class, the following code works well and soes exactly what it is supopsed to:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
   \matrix (m) [matrix of nodes]
   {
   A & B & C\\
   D & E & F\\
   };
   \draw (m-1-1)--(m-2-3);
\end{tikzpicture}
\end{document}

If I try to get the same result in beamer by doing
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}
   \begin{tikzpicture}
      \matrix (m) [matrix of nodes]
      {
      A \& B \& C\\
      D \& E \& F\\
      };
      \draw (m-1-1)--(m-2-3);
   \end{tikzpicture}
\end{frame}
\end{document}

compilation fails with
Package pgf Error: No shape named m-2-3 is known.

Using a fragile frame makes no difference. Is there a way to make the node names in a matrix of nodes work in beamer?


text:
Q: How can I align right and left of 2 divs I'm using materializecss to create a sample page, the problem is that I can't get 2 divs to alaign by the left and right padding, in a sort of way I want to expand the second div, to exactly match the first.

I have 2 divs, 1 containing an image:

css:
.maskbanner{
     background: url('https://via.placeholder.com/1031x302') no-repeat;
     background-size: contain;
     background-repeat: no-repeat;
     height: 0;
     padding-top: 30%;
}

and after that I have a div containing a row and a col:

    .. elements ..

The problem is that the class:
.row .col {
    float: left;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: 0 .75rem;
    min-height: 1px;
}

adds .75 em to the left and right of the column, I tried to give that "extra" padding to my first div trying to match that padding, but it doesn't seem to work, I also want to keep that align responsive.
Here is my project:
CodePen

A: You need to structure your html, css according to their rule. Inside container should have row and inside row should have col. So all the element inside will have the same padding, margin and it will align correctly.

In case you don't want to do that, create another css class like
.row.custom-row {
   margin-left: -0.75rem;
   margin-right: -0.75rem;
}

and add it to the row of 2nd div

    .. elements ..


text:
Q: Creating a windows lib in C++ on Windows7 using Windows10SDK I'm a little rusty when it comes to making .lib and .DLLs so please pardon my ignorance on some of the details but here is my question.
I'm making a (Universal Windows) lib in C++ using Visual Studio and Windows 7. The lib has simple convenience functions for doing things like sub-string, index of, etc.
One of these functions requires that I use the Windows 10 SDK, specifically:
StorageFolder* appFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

create_task(appFolder->GetFilesAsync()).then([=](IVectorView<StorageFile*>* filesInFolder)
{
    //Iterate over the results and print the list of files
    // to the visual studio output window
    for (auto it = filesInFolder->First(); it->HasCurrent; it->MoveNext())
    {
        StorageFile* file = it->Current;
        String* output = file->Name + "\n";
        OutputDebugString(output->Begin());
    }
});

My question is, how do I do make this lib as compatable as possible and more importantly how do I get it to work? I understand I'm using Windows7 and these classes are only available in Windows10 so I would assume I would install the Windows10 SDK and include it in my lib project but it still cant find StorageFolder. Is the only option for me to move into Windows10? Can my lib still work if the user is using it on Windows7?

A: This API that you use won't work on windows 7 or vista or any earlier.
But a suggestion is to make your code reusable as much as possible and use it to make the Universal Windows App and the Windows 7 program.
actually any New API for windows 10 won't work on windows 7 ("Microsoft's evil plan to make developers and people switch to windows 10")
i hope you find the solution.
my regards.


text:
Q: Package inputenc Error: Unicode character α (U+3B1) not set up for use with LaTeX When I compile the .tex file, I get the said error. It points out to .bbl file in the following line:
\bibitem{LIU20083883}
G.~Liu, T.~Nguyen-Thoi, K.~Lam,
  \href{http://www.sciencedirect.com/science/article/pii/S0045782508001199}{A
  novel alpha finite element method (αfem) for exact solution to mechanics
  problems using triangular and tetrahedral elements}, Computer Methods in
  Applied Mechanics and Engineering 197~(45) (2008) 3883 -- 3897.
\newblock \href {http://dx.doi.org/https://doi.org/10.1016/j.cma.2008.03.011}
  {\path{doi:https://doi.org/10.1016/j.cma.2008.03.011}}.
\newline\urlprefix\url{http://www.sciencedirect.com/science/article/pii/S0045782508001199}

How to overcome this issue? This error popped up in the new version of TeXStudio. I didn't see this while I compiled in the older version.

A: The problem is with the α in (αfem). You can either change your .bib file and replace (αfem) with ($\alpha$fem) or you can add
\DeclareUnicodeCharacter{3B1}{\ensuremath{\alpha}}

to your preamble.
The \DeclareUnicodeCharacter command will assign the code \ensuremath{\alpha} to the character  3B1.
Depending on the appearance you want to achieve for the α you can load the upgreek package and use \ensuremath{\upalpha} instead.
The \ensuremath guarantees that you can use α both in text and math mode.

A: You can edit the .bib file to read $\alpha$FEM, but there's a better method, namely loading textalpha.
\begin{filecontents*}{\jobname.bib}
@article{LIU20083883,
title = "A novel alpha finite element method (α{FEM}) for exact solution to mechanics problems using triangular and tetrahedral elements",
journal = "Computer Methods in Applied Mechanics and Engineering",
volume = "197",
number = "45",
pages = "3883-3897",
year = "2008",
issn = "0045-7825",
doi = "https://doi.org/10.1016/j.cma.2008.03.011",
url = "http://www.sciencedirect.com/science/article/pii/S0045782508001199",
author = "G.R. Liu and T. Nguyen-Thoi and K.Y. Lam",
keywords = "Numerical methods, Finite element method (FEM), Node-based smoothed finite element method (N-SFEM), Upper bound, Lower bound, Alpha finite element method (FEM)"
}
\end{filecontents*}

\documentclass{article}

\usepackage{textalpha} % <--- Greek letters in text

\begin{document}

\cite{LIU20083883}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

Note that the .bib file has to be slightly edited anyhow, because αFEM would result in

αfem

in print (and we can see it in your printout). The uppercase letters should be kept, so they should be enclosed in braces:
title = "A novel alpha finite element method (α{FEM}) for exact [...]

Also
pages = "3883 -- 3897",

should better be
pages = "3883-3897",

Note: I downloaded the .bib entry from the publisher's site.


text:
Q: Get a  element to fill remaining height in a parent div? I have a canvas, I want to show it under a piece of text. The parent div that contains both the text and the canvas has an explicit height of 200px. I want the canvas to just fill in whatever height is left over below the text div, something like:
----------------------------
|  label div               |
----------------------------
|                          |
|  canvas                  |  entire height of parent
|  fill in rest of height  |  div should be 200px.
|  (height = 100%)         |
|                          |
----------------------------

This is what I tried:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

hello

         <canvas style="background-color: rgb(0,255,128);">
         </canvas>

But notice how the canvas element spills over the bottom of the parent div:

Is there a way to just get the canvas to fill the remaining space without spilling out?
Thank you

A: You can make a label class for the div above the container and give it a height percent and set the canvas to the remaining height. I've done an example with your code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

hello

         <canvas style="background-color: rgb(0,255,128);">
         </canvas>

A: Maybe try something like this:
 ...

 ...

Notice the added css rule overflow:hidden
Here is the full usage documentation for the css rule overflow
http://www.w3.org/TR/CSS21/visufx.html


text:
Q: Need help to structure my SQL DB - groups settings I am trying to build a 'facebook groups' style application, which contains groups and each group has its own set of settings.
so I created 3 tables:
groups - (id, name..)
settings - (id, key)
groups_settings - (group_id, setting_id, value) group_id + setting_id are a primary key

and it works fine on single values settings (like min_age, max_age etc..).
but now I am facing a problem when I have a setting key which can have multiple values, for example: "allowed_countries" which is a list of allowed countries a user can join from.
I can't have multiple rows with the same group_id and setting_id, as they are under primary key constraint.
so how would you solve this problem? should I restructure my DB?

A: So you have a many-to-many relationship (users to countries.) One way to model this is to have a lookup table like so:
users table has primary key user_id (and other columns)
countries table has primary key country_id (and other columns)
user_country_mapping table has exactly two columns:

*

*user_id is a foreign key into users table

*country_id is a foreign key into countries table

That way, you can keep your data model clean.


text:
Q: What are all the possible first-words of SQL statements? I'm building a user interface to be able to execute SQL statements on a SQL Server database, compatibility at SQL Server 2008 R2. I need to be able to determine whether each statement could possibly return a dataset, or if it just needs to be executed. In Delphi, the TADOQuery consists of either Open / Close for a dataset, or ExecSQL just to execute. I need to automatically determine which one to use based on the first word(s) of the SQL statement.
How can I determine which method I should call based on the first word(s) in the statement? I would need to know each possible word, and which method based on each word.

A: That is not possible in the general sense. EXEC stored-procedure-name for example can eithers return a result set or not, depending on how the proc is written. There is no way to know if it's one or the other just from the syntax of the call.


text:
Q: Changing the Magento category URLs I am working in Magento EE 1.10.1.1,
I changed the categories URLs from admin panel, but in frond-end(menu) still the old are showing. I run re-index and clear all caches.
Can anybody know how to solve this.

A: This is my bad, the re-index takes much time to complete. It starts works once re-index completes.


text:
Q: RewriteRule rewrites to incorrect location I'm using the Mod_Rewrite module to rewrite urls.
This is my RewriteRule:
RewriteRule ^index index.php
RewriteRule ^page page.php

If I'm going to localhost/page the content of page.php is shown. But when I go to localhost/index the url get rewritten to:
http://localhost/C:/Users/Username/Documents/Xampp/htdocs/index.php

Thank you.
Edit:
The full .htaccess code:
RewriteEngine On
RewriteBase /
RewriteRule ^page page.php
RewriteRule ^index index.php
RewriteRule ^about about.php
RewriteRule ^contact contact.php

A: Problems like these are usually fixed by defining a RewriteBase (docs). Put the following directive after the RewriteEngine directive, but before any rule you have:
RewriteBase /

A: Try these rules with anchors $:
RewriteEngine On
RewriteBase /

RewriteRule ^page/?$ page.php [L]
RewriteRule ^index/?$ index.php [L]
RewriteRule ^about/?$ about.php [L]
RewriteRule ^contact/?$ contact.php [L]

Alternatively you can try this line on top of your .htaccess:
Options +MultiViews


text:
Q: What is the difference between 32-bit PAE and 64-bit kernels? I ask this only in regards to memory addressing.
I know that a PAE kernel allows the OS to access more memory than a standard 32-bit kernel, however, what are the other implications? What specific differences are there between a 64-bit kernel and a 32-bit PAE kernel?
According to Wikipedia, a processes address space remains at 32-bits, meaning it can only access a maximum of 4GB of memory. The OS however can access a 64GB address space, allocating 4GB chunks to processes.
To me it seems like this is a big distinction that seems to be ignored by many people.

A: The kernel sees the physical memory and provides a view to the processes. If you ever wondered how a process can have a 4 GB memory space if your whole machine got only 512 MB of RAM, that's why. Each process has its own virtual memory space. The addresses in that address space are mapped either to physical pages or to swap space. If to swap space, they'll have to be swapped back into physical memory before your process can access a page to modify it.
The example from Torvalds in XQYZ's answer (DOS highmem) is not too far fetched, although I disagree about his conclusion that PAE is generally a bad thing. It solved specific problems and has its merits - but all of that is argumentative. For example the implementer of a library may not perceive the implementation as easy, while the user of that library may perceive this library as very useful and easy to use. Torvalds is an implementer, so he's bound to say what the statement says. For an end user this solves a problem and that's what the end user cares about.
For one PAE helps solve another legacy problem on 32bit machines. It allows the kernel to map the full 4 GB of memory and work around the BIOS memory hole that exists on many machines and causes a pure 32bit kernel without PAE to "see" only 3.1 or 3.2 GB of memory, despite the physical 4 GB.
Anyway, for the 64bit kernel it's a symmetrical relation between the page physical and the virtual pages (leaving swap space and other details aside). However, the PAE kernel maps between a 32bit pointer within the process' address space and a 36bit address in physical memory. More book-keeping is needed here. Keyword: "Extended Page-Table". But this is somewhat more of a programming question. This is the main difference. More book-keeping compared to a full linear address space. For PAE it's chunks of 4 GB as you mentioned.
Aside from that both PAE and 64bit allow for large pages (instead of the standard 4 KB pages in 32bit).
Chapter 3 of Volume 1 of the Intel Processor Manual has some overview and Chapter 3 of Volume 3A ("Protected Mode Memory Management") has more details, if you want to read up on it.

To me it seems like this is a big
  distinction that seems to be ignored
  by many people.

You're right. However, the majority of people are users, not implementers. That's why they won't care. And as long as you don't require huge amounts of memory for your application, many people don't care (especially since there are compatibility layers).

A: You might want to look into what Linus Torwalds says about it here:

PAE turned that very simple fact on its head, and screwed things up royally. Whoever came up with the idea was totally incompetent, and had forgotten all the DOS HIGHMEM pains. There's a damn good reason why we left the 286 behind, and started using 386′s, instead of having HIGHMEM crap with windows into a bigger physical space.
[...]
So repeat after me: PAE didn't ever really fix anything. It was a mistake. It was just a total failure, and the result of hw engineers not understanding software.

A: From the view of the CPU,

*

*PAE is an external thing: the CPU has simply 36 pins to address a memory address.

*While the 64-bit is an internal thing: it uses the upper 32 bit of its registers.

From the view of the rest of the system, there is no difference if you are using a PAE or a 64-bit kernel. It can see only the signals from the CPU pins, and the CPU has 36 bits to address memory in both cases.
Of course (2) automatically includes also (1).


text:
Q: How can I call product image, details, and price on the section page in Shopify?

{% for block in section.blocks %}
{% for image in product.images %} {{ image.src | product_img_url: 'grande' }} {% endfor %}
{{block.settings.product.title}}
{{all_products[product].price | money_without_trailing_zeros }}
{% endfor %}

{% schema %}
{
"name": "Demo",
"blocks": [
{
"type": "new-arrival",
"name": "New Arrival",
"settings": [
{
"type": "product",
 "id": "product",
"label": "Product"
}

]
 }
]
}
{% endschema %}

Can anyone tell me how can I call multiple product images, product details, and product prices on the section page?
Here some code that I try but it's not correct.

A: when using the input type product into Shopify schema, you need to use the all_products object to get the details of the selected product, you need to get the details and assign it to a variable, something like this one.
{% assign product = all_products[block.settings.product] %}

Then you can use the other properties of the same object. so your code is looking.
{% for block in section.blocks %}
   {% assign product = all_products[block.settings.product] %}
   {% for image in product.images %}
     <!-- list images -->
      {{ image.src | product_img_url: 'grande' }}
     <!-- product title -->
      {{product.title}}
     <!-- product price -->
      {{ product.price | money_without_trailing_zeros }}
     <!-- product description -->
      {{product.description}}
   {% endfor %}
{% endfor %}

{% schema %}
{
   "name": "Demo",
   "blocks": [
      {
         "type": "new-arrival",
         "name": "New Arrival",
         "settings": [
            {
               "type": "product",
               "id": "product",
               "label": "Product"
            }

         ]
      }
   ]
}
{% endschema %}

You can check and read more about object all_products Link

A: Thank You for guide Onkar. I update a little bit now it properly works.

{% for block in section.blocks %}
   {% assign product = all_products[block.settings.product] %}
   {% for image in product.images %}
        <img src="{{ image.src | product_img_url: 'grande' }}" >
      {{product.title}}
      {{ product.price | money_without_trailing_zeros }}
      {{product.description}}
   {% endfor %}

{% endfor %}


text:
Q: How can I get rid of this Unauthorized Access exception? I'm trying to create a script to automate converting pub files to pdf:
Function Pub-PDF($f, $p)
{
    $Pub = New-Object -ComObject Publisher.Application
    $Doc = $Pub.Open($f)
    $Doc.ExportAsFixedFormat([Microsoft.Office.Interop.Publisher.PbFixedFormatType]::pbFixedFormatTypePDF, $p)
    $Doc.Close()
    [gc]::Collect()
    [gc]::WaitForPendingFinalizers()
    $Pub.Quit()
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($Pub)
    Remove-Variable Pub
}

Pub-PDF -f C:\Users\User\Desktop\testFolder\01_afr_mod1_00.pub -p C:\Users\User\Desktop\testFolder

This script produces the following error:
[1]: https://i.stack.imgur.com/bsbN5.png

A: The path you are passing in to your -p parameter needs to include a filename. Try something like
Pub-PDF -f C:\Users\User\Desktop\testFolder\01_afr_mod1_00.pub -p C:\Users\User\Desktop\testFolder\converted.pdf


text:
Q: How do I go about figuring out delta-epsilon proofs? I'm going through Bert Mendelson's Introduction to Topology on my own. In fact, I've tried to go through it several times and I always get stuck somewhere. This time it's on limits. I think I understand the concept of the delta-epsilon proof. I want to show that that there is a certain range and distance such that whenever a comes within a certain range of b, f(a) comes within a certain distance of f(b). I think I finally understand that. But then I get to the exercises and I am just totally at a loss. I think I spent an hour on the first one today. If you could walk me through the thought process for this kind of proof that would be awesome, because I have no idea how to even start. Here's the first problem.

Let $X$ be the set of continuous functions $f:[a,b]\to R$. Let $d$* be the distance function on $X$ defined by $$d^*(f,g)=\int_a^b|f(t)-g(t)|dt,$$ for $f,g\in X.$ For each $f\in X$, set $$I(f) = \int_a^bf(t)dt.$$
  Prove that the function $I:(X,d^*)\to (R,d)$  is continuous.

In this case, d is just the absolute value of the difference between the two numbers.

A: Fix $f\in X$, given $\varepsilon >0$ we need to find $\delta >0$ such that:
(1) $g\in X$ and  $d^*(f,g)<\delta$ imply $|I(f)-I(g)|<\varepsilon$
Observe that, if $g\in X$:
$\left |I(f)-I(g)\right |=\left | \int_{a}^{b} f(t) -g(t) dt \right | ≤\int_{a}^{b} \left |f(t) -g(t) \right | dt=d^*(f,g)$
Hence if we take $\delta = \varepsilon$ we obtain:
$\left |I(f)-I(g)\right |≤d^*(f,g)<\delta=\varepsilon$
This means that $I$ is continuous at $f$, since condition (1)  is met.
Since $f \in X$ was arbirtrary, $I$ is continuous in $X$.


text:
Q: Visual Studios (Xamrin Forms) How to add sound to a button when clicked I have been surfing google for a week now, yet I cant find how to play a sound when I press a button, all youtube videos give me the answer but on xamrin android or android studios. i want to do it on visual studios as I'm trying to build a piano app, and this is literally the key element I need.
ಠ_ಠ

A: Put mp3 in these folders , Android Assets en iOS Recourses

Property

And iOS property

Install this - pluging Xam.Plugin.SimpleAudioPlayer
To play in a Button.Clicked

var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
player.Load("Drup.mp3");
player.Play();


text:
Q: How to populate Dynamics 365 lookups with text value from Azure Logic App? I am creating an Azure Logic app which takes data from an external source and populates Dynamics 365.
In the Dynamics 365 entity, I have 4 lookup fields which I need to populate. But from the external source, I am getting data in text format, which means I need to search value for lookup fields by text instead of Guid.
I am doing this by creating an Azure function but want to know if there is any possibility to achieve this with no code customisation? External data source can only send text as Dynamics 365 guids are not synced with source.
Thanks

A: You can directly search using your logic app itself. There is an CDS connector step as "get Records", wherein you can filter query and match it based on your text criteria.
It can be you might get more than 1 record, ex: Account name: ABC company can be double in your crm.
you might want to narrow it down to fetch the desired result.
Once you get your Record you can use record and it's guid to fill your Lookup Field.
Refrence to get Records
Here is latest Microsoft Doc for fetching record in logic apps


text:
Q: kde plasma autostart does not honor redirection or multiple commands I used to have an autostart login script in archlinux/kde, that had the following exec line:
Exec=rmdir /var/tmp/screensaver.lock; /home/user/bin/screensaver.sh > /tmp/screensaver.log 2>&1

but now for some reason it stopped working. If I write it like this:
Exec=/home/user/bin/screensaver.sh

it works.
It looks like kde can't handle the multiple commands and the redirections. why?
Thanks

A: I found a solution for this. Run everything inside 'bash -c' command.
Exec=bash -c "rmdir /var/tmp/screensaver.lock; /home/user/bin/screensaver.sh > /tmp/screensaver.log 2>&1"


text:
Q: Some difficulties in Python on Begginer level Sorry if I'm asking something dumb. I'm begginer btw.
Can I somehow place multiple variables in one variable, like:
login = "user"
enter = input(login + ">")
commandLogin = "login"
commandRegister = "register"
commandExit = "exit"
commandList = commandLogin, commandRegister, commandExit

while enter != commandList:
    print("incorrect command!")
    enter = input(login + ">")

A: Well, in the example you're already doing that.
The main correction is that you probably want while enter not in commandList

A: You can use an 'iterable', such as a tuple or a list. Check here: Python docs
So for your code you can use:
login = "user"
commandLogin = "login"
commandRegister = "register"
commandExit = "exit"
commandList = [commandLogin, commandRegister, commandExit]

enter = input(login + ">")
while enter not in commandList:
    print("Incorrect command!")
    enter = input(login + ">")

A: Sure. You can use a dictionary to put multiple variables in one variable:
>>> a={}
>>> a['first']='this is the first'
>>> a['second']='the second'
>>> a
{'first': 'this is the first', 'second': 'the second'}
>>> a['first']
'this is the first'
>>>

You can also create a class, an object of the class, and access attributes:
>>> class Empty():
...     pass
...
>>> a = Empty()
>>> a.first = 'the first value'
>>> a.second = 'the second value'
>>> a
<__main__.Empty object at 0x7fceb005dbd0>
>>> a.first
'the first value'
>>> a.second
'the second value'
>>> a.third
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Empty' object has no attribute 'third'
>>>

In your example, you probably want to use a list:
>>> a = []
>>> a.append("first")
>>> a.append("second")
>>> a.append("third")
>>> a
['first', 'second', 'third']
>>>

But it's not really clear what you are trying to do in your example.

A: The result of this is a tuple. A tuple is similar to a list but once a tuple is created, the values cannot be changed. The technique in the code is called tuple packing and essentially just creates a tuple.

A: When you separate multiple variables by comma without any surrounding parenthesis, python creates a tuple for you:
a = 1
b = 2
c = 3

# implicit tuple
x = a, b, c

# equivalent, explicit tuple
x = (a, b, c)

Likewise, you can expand a tuple (or any iterable) into multiple variables:
# Expanding a tuple
x = (1, 2, 3)
a, b, c = x  # a=1, b=2, c=3

# Expanding a list
x = [1, 2, 3]
a, b, c = x  # a=1, b=2, c=3

# Expanding a dict (the keys are expanded into the new variables)
x = {'a': 1, 'b': 2}
a, b = x  # a = 'a', b = 'b'

# Expanding an iterator
a, b = range(2)  # a=0, b=1

A: So you can do it by many ways, i'll give you two of them!
You can always try to get to know some other ;)
You can do a list(changeable list) like this : colors = ["white", "blue", "red"].
Or you can do a tuple ( non-changeable list ( you can change the variable, but not the list itself )) like this : colors = ("white", "blue", "red")

A: Yes You can Place multiple Variable
but avoid it
https://www.geeksforgeeks.org/assigning-multiple-variables-in-one-line-in-python/