Thursday, 3 October 2013

mongodb complex query on nested array

mongodb complex query on nested array

I have a single document in MongoDb whose structure is something like this
.. NESTED ARRAY. I want to $addToSet into d:["x","y"] to make it
d:["x","y","z"].
I have tried out $elemMatch and $. But they only work at a SINGLE LEVEL of
array.
{
id:1,
a:[
{
id:2,
b:[
{
id:3,
c:[
{
id:4,
d:["x","y"]
},
{
id:5,
d:["p","q"]
}
]
},
{
id:13,
c:[
{
id:14,
d:["w","q"]
},
{
id:15,
d:["i","j"]
}
]
}
]
}
]
}
What will be the query to get d:["x","y","z"] where query part could be ..
{id:1, "a.id":2, "a.b.id":3, "a.b.c.id":4 } or may be using $elemMatch ?

Wednesday, 2 October 2013

Wait for Android animation to finish

Wait for Android animation to finish

I was wondering if anyone could help me out, I've been looking everywhere
for usefull help, but found nothing. I have four View elements (Buttons),
and I need to animate them, in random order, one after the other. I've
tried waiting for Animation.hasEnded(), that just freezes the entire app.
Also I tried waiting for an AnimationListener to change a boolean from
onAnimationEnd(), but that also froze the app. Both Thread.sleep() and
SystemClock.sleep() for waiting gave the same result. Please, can someone
help me?

Make a matrix with putting zeros between numbers in every rows

Make a matrix with putting zeros between numbers in every rows

I want make a 4*P matrix from P numbers
P=p1+p2+p3+p4
X=[x11 ... x1p1 0...0 0...0 0...0 ; 0...0 x2p1+1 ... x2p2 0...0 0...0 ;
0...0 0...0 x3p2+1 ... x3p3 0...0 ; 0...0 0...0 0...0 x4p3+1 ... x4p4]
there are values in pi of P elements in every row and other elements of
row are zero for example input=[1,2,3,4,5,6,7,8,9] p1=1, p2=2, p3=3, p4=3
X=[1 0 0 0 0 0 0 0 0; 0 2 3 0 0 0 0 0 0; 0 0 0 4 5 6 0 0 0; 0 0 0 0 0 0 7
8 9]
thanks

what the hell ubuntu has with amd processor

what the hell ubuntu has with amd processor

I'm using ubuntu since three year and loves it. But now problem is that I
can't install ubuntu on my pc which has amd processor. I tried all the
solution regard my problem but it didnt work. I was loving ubuntu and
hating to windows but now I think that windows is much better than ubuntu.

migrate to a page from personal account

migrate to a page from personal account

I'm trying to migrate a personal account to a bussines page, but when I do
the process I get an alert that says, "please access from a computer from
which you previously login facebook" ('m comunity manager, entered daily
from my computer ) Is this a bug? How I can fix it? thnks!

Tuesday, 1 October 2013

How to read a txt file line by line in R/RstudioH

How to read a txt file line by line in R/RstudioH

Suppose I have a messy text file like the following for example
Today is a good
day, but I feel very tired. It seems like it is
going to rain pretty soon.
I want to read the txt file into R as a character vector exactly the way
it appears as in the original text file. In other words, I want to have
the first element of the character vector being the first line, second
element of the character vector being the second line, etc, as below
char_vector[1] = "Today is a good"
char_vector[2] = "day, but I feel very tired. It seems like it is"
char_vector[3] = "going to rain pretty soon."
I have tried read.table and read.csv, but it's always the case that some
lines join together as one line. Is there a way to fix this?

Unable to resolve symbol 'ExecutionInfo'

Unable to resolve symbol 'ExecutionInfo'

I'm getting "Unable to resolve symbol 'ExecutionInfo'" when trying to use
ReportingService2010. ExecutionInfo and ExecutionHeader worked in
ReportingService2005. I'm using Visual Studio 2010, VB.Net, and Reporting
Services 2010. I can connect to the server and do things like
rs.ListChildren.
Any Ideas?

Should you ask a question asker to accept an answer=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=

Should you ask a question asker to accept an answer? – meta.stackoverflow.com

What I often see is questions that gets answered where the asker of the
question says "thank you this was exactly what I was looking for" in the
comments but forgets to mark the answer as ...

What is apache handlers equivalent in Lighttpd

What is apache handlers equivalent in Lighttpd

Hi experts can somebody give some clues about this.
In httpd.conf we use user defined handlers like
AddHandler ctc-handler getLauncher
What is the equivalent of userdefined apache handlers in Lighttpd.

Monday, 30 September 2013

Installation Of Ubuntu has no menus

Installation Of Ubuntu has no menus

I have installed 13.04 from DVD. I have a blank Ubuntu screen with a
background. I have no menu or dash. How do I get a menu, etc.?

how to (if possible) create a SSL certificate for only one website on my apache2 server?

how to (if possible) create a SSL certificate for only one website on my
apache2 server?

I saw some similar posts like this , but it didn't help me at my exact
problem. So I am using ubuntu 12.04 on a server with apache2 on it. There
are like 5 websites which are Virtualhosts and Namebased running on it
(using the same port). Now I need another page whiche REQUIRES a SSL
certificate. Is it possible to run just the one page under ssl or do I
automatically load everything in it when I configure SSL ?
I know that I have to put the SSL server under Port 443 like this :
<virtualhost *:443>
SSLEngine On
SSLCertificateFile /path/to/your/sslcert
DocumentRoot /path/your/webcontent
</virtualhost>
Does anyone know and want to explain me, how to setup ssl for just one page?

Magento - How to clean up attributes not in attribute set

Magento - How to clean up attributes not in attribute set

I am taking over a website from another developer, and have found the
setup of attributes to be a bit of a mess.
Specifically, products have attributes that aren't associated with the
relevant attribute sets.
If you take wine with an attribute set "Wines", one of whose attributes is
"Grape Variety".
But I also have "Beers" with a completely different attribute set, but
somehow one of my beers has a Grape Variety.
It's not assigned to the Beers attribute set, it doesn't show up in the
back end for this product, (so I can't edit it) but if I look in the
database it's there (in catalog_product_entity_* and
catalog_product_index_eav), furthermore when I do an export it's there
too, and if someone searches for "Merlot", they are coming up with this
beer. There are hundreds of products like this.
What is the best way of removing all attributes from products that are not
within their assigned attribute sets?
I could figure it out in SQL I'm sure, but that's not the best way of
doing things as I'd be afraid of missing something and screwing up the
products altogether.

Is there a limit to “else if” statements?

Is there a limit to "else if" statements?

I would like to ask there a limit on how many "else if" clause we can put?
I have been told that if we are having too many "else if", it will lead to
stack overflow eventually. For example:
if (1 > 1){}
else if (1 > 2){}
else if (1 > 3 ){}
//and so on
else{}
However, I can't find any evidence on this subject, and Googling doesn't
give me the answer that I want. The question below is has the same title,
but has nothing related to the subject that I wanted to ask. Thanks in
advanced.
Javascript: Is there a limit to "else if" statements?

Sunday, 29 September 2013

Positioning of Search Bar

Positioning of Search Bar

I have inserted a search bar by using my websites code injection points
and now trying to re position it below my site tag line. Below in an
screenshot of what I am trying to accomplish.
My website is www.jobspark.ca
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("#banner-area").prepend("<div id='banner-tagline'>Your British Columbia
and Alberta Job Search</div>");
});
</script>
<div class="positionedSearch"></div>

Current CSS for the search bar includes
.positionedSearch {
width: 400px;
height: 45px;
}

Get the Value from a Slider when the slider is moved (in Limesurvey)

Get the Value from a Slider when the slider is moved (in Limesurvey)

i'm working with Limesurvey and Javascript for the first time. I want to
get the value of a slider everytime it is moved. I didn't know how to do
this properly. Until now it got something like:
$(document).ready(function() {
$( "#slider-handle-576875X1492X18245SQ001" ).click(function() {
alert($( ".ui-slider-handle ui-state-default ui-corner-all"
).slider( "value"));
});
});
And this works so far, that everytime i click the slider, i get a alert,
but it only gives me [objetc Object] and not the value.
I'm not sure how i can get the value, because if i look at the html code
of the slider, the value (at this moment 14) is stored anywhere, just in
percentage via style="left: 46.666666666666664%;">
I just post it here so you can have a look!
<div id="slider-576875X1492X18245SQ001" class="ui-slider-1 ui-slider
ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">
<div id="slider-left-576875X1492X18245SQ001" class="slider_showmin">0</div>
<div class="slider_callout" id="slider-callout-576875X1492X18245SQ001"
style="left: 93.32386016845703px;">14</div>
<div class="ui-slider-handle ui-state-default ui-corner-all"
id="slider-handle-576875X1492X18245SQ001" style="left:
46.666666666666664%;"></div>
<div id="slider-right-576875X1492X18245SQ001"
class="slider_showmax">30</div>
</div>
<div id="slider-left-576875X1492X18245SQ001" class="slider_showmin">0</div>
<div class="slider_callout" id="slider-callout-576875X1492X18245SQ001"
style="left: 93.32386016845703px;">14</div>
<div class="ui-slider-handle ui-state-default ui-corner-all"
id="slider-handle-576875X1492X18245SQ001" style="left:
46.666666666666664%;"></div>

Codeigniter routes 404

Codeigniter routes 404

I have a website on a local wamp server (I have used a virtual host
setup). However when I try to link to another controller on the site, I
just get a 404 page (not codeigniters 404). I'm sure I'm missing something
simple, but what I'm not quite sure.
If in the url I put the website.co.uk/index.php/aboutus I get the page
(although it's not got any of my formatting there).
I'm trying to have links in the format: website.co.uk/aboutus
Here is my routes.php
$route['404_override'] = '';
$route['default_controller'] = 'home';
$route['(:any)'] = '$1';
Here is my controller that I'm trying to link to:
class Aboutus extends CI_Controller {
public function index()
{
// $this->load->library('parser');
// $this->load->view('header_view');
// $this->loadContent();
// $this->load->view('footer_view');
$this->load->helper(array('form', 'url'));
$data = array();
$data["title"] = "Our Story";
$data["page_content"] = "here is some page content";
$this->load->view('aboutus_view', $data);
}
}
I am using the follow href tag for the link
<a href="<?php echo site_url('aboutus'); ?> ">
In my config file I have
$config['base_url'] = '';
$config['index_page'] = '';
Has anyone got any ideas as to what I'm missing?
Thank you.

Variadic template pointer to member function declaration/usage issues

Variadic template pointer to member function declaration/usage issues

// This compiles and runs properly
using MemPtr = Entity&(OBFactory::*)(const Vec2i&, float);
void test(MemPtr mptr, const Vec2i& p, float d)
{
(getFactory().*mptr)(p, d);
}
// "no matching function for call to `test`,
// failed candidate template argument deduction"
template<typename... A> using MemPtr = Entity&(OBFactory::*)(A...);
template<typename... A> void test(MemPtr<A...> mptr, const Vec2i& p, float d)
{
(getFactory().*mptr)(p, d);
}
...
// I call both versions with
test(&OBFactory::func, Vec2i{0, 0}, 0.f);
Why doesn't the variadic template version work? Am I missing some forwarding?

Saturday, 28 September 2013

Certain Normal Subgroups of a Free Group

Certain Normal Subgroups of a Free Group

Let $F$ be a free group on some set $X$. For any $x \in F$ and $n \in
\mathbb{Z}$, we have that $\langle x^n \rangle \lhd F$. Why does this
hold?
For any word $w \in F$, we have $wx^n w^{-1} = (wxw^{-1})^n$ and hence it
seems to suffice to show that $wxw^{-1} = x^k$ for some $k \in
\mathbb{Z}$, but I am not sure why this should be the case.

Submit data in chat app - should I have a button?

Submit data in chat app - should I have a button?

I'm building a chat application on a website. I don't know anyone who uses
their mouse to send the chat messages, rather that just hitting
return/enter. 10 years ago you always had a button as a alternative to
using your enter key. Although, take a look at Google Chrome, they don't
have a button to hit after you have entered your url. A few years back
they had. Now it's just enter.
Would there be any consequences of not having a button?

How do I create a registration, login/logout form, and a profile page for users in php

How do I create a registration, login/logout form, and a profile page for
users in php

I've asked questions before on how to connect to the database using
000webhost, I've failed many times on connections and what not. I need
some help on creating a sign up form and email verification and a
login/logout form. I am a beginner web developer, should I switch to a
different hosting provider because all the creditials for 000webhost are
to complicated and I just want a simple database connection that would
actually work for me. What hosting provider should I switch too? Here's my
code I am having trouble with connecting to the database:
<?php
$email = $_POST['email'];
if ($email == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$username = $_POST['username'];
if ($username == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$password = $_POST['password'];
if ($password == null) //add more tests as needed.
{
die("You must fill out everything on the form!");
}
else
{
//continue...
}
$connect = mysql_connect (
$host = $mysql#.000webhost.com;
$dbuser = $#####_#####;
$dbpass = $########;
$db = $#####_######;
$siteurl = http://#######.site90.com/;
$sitemail = autoresponder@#####.site90.com;
$domain = http://#########.site90.com/;
)
if (!$connect)
{
die('Could not connect: WHAT THE FUCK ' . mysql_error());
}
else
{
mysql_select_db('######_#####', $connect);
$alreadyexists = mysql_query("SELECT password FROM tbl_users WHERE
email = $email");
if ($alreadyexists != null)
{
die('This email has already been registered. Please use a different
email.');
}
$alreadyexists = mysql_query("SELECT password FROM tbl_users WHERE
username = $username");
if ($alreadyexists != null)
{
die('This username has already been registered. Please use a different
username.');
}
mysql_query("INSERT INTO Persons (username,email,password)
VALUES ($username,$email,$password)");
}
?>