Thursday, 3 October 2013

Unmatched response on ItemLook Up based on UPI

Unmatched response on ItemLook Up based on UPI

I have tried using ItemLook operation to identify an ItemId based on UPC
IdType. I expected to get a unique result, since it is based on UPC. But
for some of the queries made, more than one result came up and sometimes,
items clearly not related to the UPC comes up in response.
For example, made a lookup for "035000530271" item, which is a kitchen
degreaser. I got three responses for it: two of which were from the same
brand and variants, but the third response was of a metal surface polish.
How did this happen? UPC of an item linked to something totally different?
I was hoping that I could make use of Amazon APIs to uniquely identify an
item from its barcode number and get price details. Can you please help me
understand, if this is expected, ie more than one responses, even if its
based on UPC? Or if there is some other way of fine tuning the lookup to
pin point to correct result?
Thanks!

Wednesday, 2 October 2013

C# like List in VBA

C# like List in VBA

I'd like to create a List<T> on VBA like you create on C#, there is any
way I can do that? I looked for questions about it here on SO, but I could
not find any.

Mapping multiple functions, in order, over a single list

Mapping multiple functions, in order, over a single list

I would like to map three different functions, in order, over a single
list. To demonstrate what I mean, say we want to do the following three
mappings:
(map foo mylist)
(map bar mylist)
(map foobar mylist)
If we define mylist as '(1 2 3), and we run the above functions one at a
time, we get:
(map foo mylist) ===> (foo1 foo2 foo3)
(map bar mylist) ===> (bar1 bar2 bar3)
(map foobar mylist) ===> (foobar1 foobar2 foobar3)
Instead, I would like the output to be in the following format:
===> ((foo1 bar1 foobar1) (foo2 bar2 foobar2) (foo3 bar3 foobar3))
How would you go about this?

#EANF#

#EANF#

I need to allow users on my website to delete their images off the server
after they have uploaded them if they no longer want them. I was
previously using the unlink function in PHP but have since been told that
this can be quite risky and a security issue. (Previous code below:)
if(unlink($path.'image1.jpg')){
// deleted
}
Instead i now want to simply move the file into a different folder. This
must be able to be done a long time after they have first uploaded the
file so any time they log into their account. If i have the main folder
which stores the users image(s):
user/
and then within that a folder called del which is the destination to put
their unwanted images:
user/del/
Is there a command to move a file into a different folder? So that say:
user/image1.jpg
moves to/becomes
user/del/image1.jpg

Tuesday, 1 October 2013

Algorithm: How to generate a virtual box to include all the points

Algorithm: How to generate a virtual box to include all the points

I am thinking to use a algorithm to create a virtual box to include all
the points in. Here is the example:
1) Original points:
2) The result should look like this:
I've tried to use convex hull algorithm, however, the result will include
white space in the virtual box which is not what I want. It is better to
remove as much as white space. (space that not includes any points). (Each
point has x and y value)
If you guys can provide some idea that will be great. Thanks!!!

mysqli_query() expects parameter 1 to be mysqli, null given in

mysqli_query() expects parameter 1 to be mysqli, null given in

My error messages
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in
/home/orikina/public_html/peacce/php/peacce.sys.php on line 30
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null
given in /home/orikina/public_html/peacce/php/peacce.sys.php on line 31
My code:
$usernameCheck = mysqli_query($myCon, "SELECT * FROM `users` WHERE
`username` = 'username'");
if (mysqli_num_rows($usernameCheck) > 0)
{
mysqli_query($myCon, "INSERT INTO users (username,
password, email)
VALUES ('$username', '$passwordReal', '$email')")
or die();
$usernameCheck = mysqli_query($myCon, "SELECT * FROM
users WHERE `username` = 'username'");
if (mysqli_num_rows($usernameCheck) > 0)
{
header("location: ../register.php?data=registerSuccess");
}
else
{
header("location:
../register.php?data=registerError&&refine=3");
}
}

Can we graph $x^{\infty}-y^{\infty}=1$

Can we graph $x^{\infty}-y^{\infty}=1$

Playing around with exponents on $x^{n}-y^{n}=1$ suggests a trend toward
cleaner and cleaner corners as n increases on one graph for even numbers
and a second graph for odd numbers. Therefore, is it possible to graph the
case of $n=\infty$ for odd and/or even numbers (separately)?

Find asymptotic of recurrence sequence – math.stackexchange.com

Find asymptotic of recurrence sequence – math.stackexchange.com

Given a sequence $x_1=\frac{1}{2}$, $x_{n+1}=x_n-x_n^2$. It's easy to see
that it limits to $0$. The question is: is there exists an $\alpha$ such,
that $\lim\limits_{n\to\infty}n^\alpha x_n\neq0$. …

Monday, 30 September 2013

To find out the minimum amount of fuel

To find out the minimum amount of fuel

There is a ship which can carry $K$ creatures at a time. There are two
types of creatures $D$ and $U$. They are to be carried from one side of
the river to the other side, with the constraint being $D$ can never be
greater than $U$ on either side of the river. The amount of fuel needed
for each trip from one side to the other side is $X$. I have to find the
minimum amount of fuel needed to carry all creatures across to the other
side. How to solve this?
example- $3, 3, 2, 10$ Output-$110$

Wifi on Lenovo N581 blocks other wifi clients

Wifi on Lenovo N581 blocks other wifi clients

I have a problem with the wifi on my new Lenovo IdeaPad N581: the wifi
works after installing the additional drivers, but when I switch it on all
other computers connected to our wifi router (the french freebox), I have
no internet access anymore.
If I boot windows it works fine. The card is a broadcom BCM4313 802.11bgn,
the driver shown by lsmod is cfg80211 or wl.

How to know the current Xpath?

How to know the current Xpath?

I am currently using a Xpath Reader to go through my xml file.
What i need is a method for knowing the current Xpath. After some search i
can't find online documentation on the methods of Xpath Reader..
Does anyone know of it?
XmlTextReader xtr = new XmlTextReader(bodyPart.Data);
XPathCollection xc = new XPathCollection();
//the code between theese two lines is not here due to its size,
//but it fills the XpathCollection
XPathReader xpr = new XPathReader(xtr, xc);
while (xpr.ReadUntilMatch())
{
//What i need is a method, to be called in the reading cycle,
//that when called returns the current Xpath.
}
Does anyone knows of it?
Thank you

Filtered arrays and since() functionality in ember-data

Filtered arrays and since() functionality in ember-data

I have a backend resource that contains user activities and in the
application I would like to present activities based on a single day's
worth of activities. I have an ArrayController called ActivitiesController
defined in the router like this:
this.resource('activities', { path: '/activities/:by_date' }, function() {
this.route('new');
});
The REST API provides the following GET method:
GET /activities/[by_date]
So far this looks pretty symmetrical and achievable but I'm running into
two problems:
Parameterized array find. Typically a parameterized route would be
serviced by a ObjectController but in this case the by_date parameter
simply reduces/filters the array of activities but it's still an array
that's returned. I'm not sure how to structure this in the model hook in
the ActivitiesRoute so that its effectively doing a "findAll" rather than
expecting a singular resultset.
Since functionality. As there is a reasonable network cost in bringing
back these arrays of activities I would like to minimize this as much as
possible and the REST API supports this by allowing for a since parameter
to be passed along with the date of the last request. This way the server
simply responds with a 304 code if no records have been updated since the
last call and if there are new records only the new records are returned.
Is there anyway to get this "out of the box" with ember-data? Does this
require building a custom Adaptor? If so, are there any open source
solutions that are available?

Sunday, 29 September 2013

consuming REST API with C#

consuming REST API with C#

I'm very new to C# and want to learn how to make HTTP requests. I want to
start really simple, although that is currently evading me. I want to just
perform a GET on, say, google.com. I created a command line application,
and have this code. Not sure at all which usings are required.
I tested it by writing to the console, and it doesn't get past the
response. Can somebody please clue me in? I'm looking to do some simple
curl type stuff to test an existing API. Thank you for your help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
namespace APItest
{
class testClass
{
static void Main(string[] args)
{
string url = "http://www.google.com";
Console.WriteLine(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
Console.ReadKey();
}
}
}

How to compare a string with a string in pointer in c++

How to compare a string with a string in pointer in c++

I am implementing linked list in c++. In that am trying to compare a data
stored in the node with a string. Here is my code:
String f;
cin>>f;
if(strcmp(temp->data,f)==0)
{ cout<<"same"; }
else
{ cout<<"not same"; }
Here is my error:
"assignment1.cc", line 160: Error: Cannot cast from std::string to const
char*.
"assignment1.cc", line 160: Error: Cannot cast from std::string to const
char*.
How to compare those two strings?

JOIN 3 tables for search

JOIN 3 tables for search

I have 3 tables: Session, Film and Vendor
Session.FilmID
Film.VendorID
Vendor.VendorName
I want to include the VendarName in the search.
Here's what I have:
sql ="SELECT SessionID, Identifier, SessionType.SessionTypeName, Film.*,
Vendor.*,
CameraID, Date FROM Session "
sql = sql + "JOIN SessionType USING (SessionTypeID) "
sql = sql + "JOIN Film USING(FilmID) "
sql = sql + "JOIN Vendor ON Film.VendorID = Vendor.VendorID "
sql = sql + "WHERE Session.Identifier LIKE ('%" + search + "%') OR "
sql = sql + "Session.Notes LIKE('%" + search + "%') OR "
sql = sql + "SessionType.SessionTypeName LIKE ('%" + search + "%') "
sql = sql + "Film.Vendor.VendorName LIKE ('%" + search + "%') "
sql = sql + "ORDER BY Identifier,SessionType.SessionTypeName"
What am I doing wrong?

How to ask webcam to auto focus with Unity3D

How to ask webcam to auto focus with Unity3D

Friends, Currently, i am working on some Augmented reality mobile App with
Unity3D. The performance is impacted by the image quality. Is there some
way to ask webcam to auto focus with Unity3D? Thank you~

Saturday, 28 September 2013

Jumping / Jitter for DIV Hover state

Jumping / Jitter for DIV Hover state

I just cant seem to fix this issue where on hover, the DIV expands and
then shrinks giving a "jumpy" or "jitter" look.
I have a list which will be for images and I want the hover state to be an
block that is 10px less than its parent;
Here is my fiddle:
Here is my code;
HTML
<div id="container">
<li class="item w2 h2"> <div class="inner"></div></li>
<li class="item w2 h2"> <div class="inner"></div></li>
<li class="item w2 h2"> <div class="inner"></div></li>
<li class="item w2 h2"> <div class="inner"></div></li>
<li class="item w2 h2"> <div class="inner"></div></li>
<li class="item w2 h2"> <div class="inner"></div></li>
</div>
CSS - the inner class is the one with the hover
#container {
padding: 5px;
margin: 0 auto;
border: 2px solid black;
}
.item {
display:block !important;
list-style:none;
float: left;
background: #CCC;
margin: 5px;
width: 50px;
height: 50px;
}
.item.w2 { width: 300px; }
.item.h2 { height: 200px; }
.inner {
background:#fff;
background: rgba(255, 255, 255, 1);
position: absolute;
top: 10px;
left: 10px;
bottom: 10px;
right: 10px;
margin:0;
padding:0;
text-align: center;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: opacity .4s ease-in-out;
-moz-transition: opacity .4s ease-in-out;
-ms-transition: opacity .4s ease-in-out;
-o-transition: opacity .4s ease-in-out;
transition: opacity .4s ease-in-out;
}
.inner:hover {
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=95)";
filter: alpha(opacity=95);
opacity: .95;
z-index:1;
}
/* no transition on .isotope container */
.isotope .isotope-item {
/* change duration value to whatever you like */
-webkit-transition-duration: 1s;
-moz-transition-duration: 1s;
transition-duration: .6s;
}
.isotope .isotope-item {
-webkit-transition-property: -webkit-transform, opacity;
-moz-transition-property: -moz-transform, opacity;
transition-property: transform, opacity;
opacity:.5;
}
Consequently the "jumpy" or "jitter" disappears when there is no
-transition such as ease-in-out or opacity.
I appreciate anyone who has a look! any suggestions would be great this is
a huge learning curve for me :)

Is it possible to upgrade Apache to 2.2.25 in Webmin/CentOS 5.9?

Is it possible to upgrade Apache to 2.2.25 in Webmin/CentOS 5.9?

I've been tasked with upgrading to Apache 2.2.25 because of PCI compliance
issues. I tried but only managed to break Apache.
Does anyone know if it's even possible to upgrade to Apache 2.2.25 under
this server config? Or do we need to upgrade to CentOS 6x to achieve this?
Trying to test it over the weekend, so any help would be greatly appreciated!

Current time - past time = human readble time

Current time - past time = human readble time

I have got a function form form SC to get human readable time.
function human_time ($time)
{
$time = time() - strtotime($time); // to get the time since that moment
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}
And I have time as string: 2013-09-28 20:55:42
when I call this function human_time('2013-09-28 20:55:42')
then it return nothing, why ? I have added strtotime in above function.
Please tell me what is wrong.

insert multiple arrays to database

insert multiple arrays to database

I am creating a multiple choice quiz and I don't know how to insert
multiple arrays to database. Please help. Here is my code.
<?php
if(isset($_POST['btnCreate'])) {
$inQuestion = array($_POST['inQuestion']);
$inAnswer = array($_POST['inAnswer']);
$inA = array($_POST['inA']);
$inB = array($_POST['inB']);
$inC = array($_POST['inC']);
$inD = array($_POST['inD']);
$inLesson = $_POST['inLesson'];
$inQuizNo = $_POST['inQuizNo'];
$sql = "SELECT * FROM lessons WHERE title='$inLesson'";
$query = mysql_query ($sql);
$row = mysql_fetch_assoc($query);
$lessonID = $row['lessonID'];
foreach(array_combine($_POST['inQuestion'], $_POST['inAnswer']) as
$question => $answer) {
$sql = "INSERT INTO `test` (question, answer, A, B, C, D,
lessonID, quizNo) VALUES ('$question', '$answer', '$_POST[A]',
'$_POST[B]', '$_POST[C]', '$_POST[D]', '$lessonID',
$inQuizNo)";
$query = mysql_query( $sql );
}
}
?>