Combining last-of-type and hover
I have the following html structure:
<ul>
<li>
<a href="#"> Superlevel 1 </a>
<span class="actions">Somes actions</span>
<ul>
<li>
<a href="#">Level 1 </a>
<span class="actions">Other actions</span>
<ul>
<li>
<a href="#">Sub-Level1</a>
<span class="actions">Sub Level actions</span>
</li>
<li>
<a href="#">Sub-Level1</a>
<span class="actions">Sub Level actions</span>
</li>
</ul>
</li>
</ul>
<li>
</ul>
The css is this:
.treeview li .actions {
float: left;
padding: 0 15px;
visibility: hidden;
}
.treeview li:hover > .actions {
visibility: visible;
}
The problem is that when I pass the mouse over the last li (sub-level 1)
the .actions of its parents Level1 and Superlevel1 are displayed. I would
like only sub-level1 .actions to be displayed.
So I have tried to replace last css block by:
.treeview li:hover:last-of-type > .actions {
visibility: visible;
}
but the last-of-type pseudo-selector is applied to li not to li:hover.
Any idea of how to combine these two pseudo-selectors ?
Thursday, 3 October 2013
Wednesday, 2 October 2013
java weird increment syntax
java weird increment syntax
So I have always been taught that in Java, using the increment operator
after a variable name in an expression will do the expression, and then
increment the value and using the operator before a variable name in an
expression will do the increment before the evaluation. Like this:
int x = 0;
int y = x++;
after this executes y should be 0 and x should be 1. and in this example
int x = 0;
int y = ++x;
should be x = 1 and y = 1.
Following that same logic, the following...
int x = 0;
int y = 0;
x = y++ - y++;
should output 0 as x and 2 as y because 0 - 0 = 0. However the output is
x = -1
y = 2
Why is this?
Edit: the value of y does not matter. x will always equal -1 and y will
(in the end) equal y + 2.
So I have always been taught that in Java, using the increment operator
after a variable name in an expression will do the expression, and then
increment the value and using the operator before a variable name in an
expression will do the increment before the evaluation. Like this:
int x = 0;
int y = x++;
after this executes y should be 0 and x should be 1. and in this example
int x = 0;
int y = ++x;
should be x = 1 and y = 1.
Following that same logic, the following...
int x = 0;
int y = 0;
x = y++ - y++;
should output 0 as x and 2 as y because 0 - 0 = 0. However the output is
x = -1
y = 2
Why is this?
Edit: the value of y does not matter. x will always equal -1 and y will
(in the end) equal y + 2.
Error when uploading a big image with CodeIgnitor
Error when uploading a big image with CodeIgnitor
I try to upload big images (>~1.5MB) to my website using PHP but the file
dont appear on the server. Sometimes I get Error 1 (Max size exceeded).
Is there anything I can do?
public function do_upload($field) {
$config['upload_path'] = './uploads/';
$config['max_size'] = '100000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($field)) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
/*$data = array('upload_data' => $this->upload->data());
return $data;*/
$updata =$this->upload->data();
$data = $updata['raw_name'].$updata['file_ext'];
return $data;
}
}
Here can I call the function:
$pic = $this->do_upload('inputUpProfile');
Here I save the picture to the database:
if ($this->input->post('post') == ''){
$type="image";
} else {
$type="image-with-text";
}
} else {
$pic = "";
$type = "text";
}
$result = $this->blog->addPost($_SESSION['user_id'], $type ,
$this->input->post('post'),$pic);
}
Models:
function addPost($user_id, $post_type, $post , $pic ) {
$today = date("Y-m-d H:i:s");
$vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type,
'ev_text' => $post,'ev_pic' => $pic, 'ev_date' => $today);
$this->db->insert($this->table_name, $vales);
}
The error:
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO events (ev_user_id, ev_type, ev_text, ev_pic, ev_date) VALUES
(1, 'image', '', Array, '2013-10-02 23:32:50')
I try to upload big images (>~1.5MB) to my website using PHP but the file
dont appear on the server. Sometimes I get Error 1 (Max size exceeded).
Is there anything I can do?
public function do_upload($field) {
$config['upload_path'] = './uploads/';
$config['max_size'] = '100000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($field)) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
/*$data = array('upload_data' => $this->upload->data());
return $data;*/
$updata =$this->upload->data();
$data = $updata['raw_name'].$updata['file_ext'];
return $data;
}
}
Here can I call the function:
$pic = $this->do_upload('inputUpProfile');
Here I save the picture to the database:
if ($this->input->post('post') == ''){
$type="image";
} else {
$type="image-with-text";
}
} else {
$pic = "";
$type = "text";
}
$result = $this->blog->addPost($_SESSION['user_id'], $type ,
$this->input->post('post'),$pic);
}
Models:
function addPost($user_id, $post_type, $post , $pic ) {
$today = date("Y-m-d H:i:s");
$vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type,
'ev_text' => $post,'ev_pic' => $pic, 'ev_date' => $today);
$this->db->insert($this->table_name, $vales);
}
The error:
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO events (ev_user_id, ev_type, ev_text, ev_pic, ev_date) VALUES
(1, 'image', '', Array, '2013-10-02 23:32:50')
VMWare WSX over internet
VMWare WSX over internet
I have VMWare Workstation 10 on my computer. I have also installed VMWare
WSX and shared a Virtual Machine. I can access this VM by going to
http://localhost:8888 (default port for test purposes). However, I would
like to be able to access this web portal pretty much anywhere from the
internet.
I've read that using dynamic DNS services would achieve this goal but I'm
not sure on how to properly configure this. Is what I'm trying to do
possible?
I have VMWare Workstation 10 on my computer. I have also installed VMWare
WSX and shared a Virtual Machine. I can access this VM by going to
http://localhost:8888 (default port for test purposes). However, I would
like to be able to access this web portal pretty much anywhere from the
internet.
I've read that using dynamic DNS services would achieve this goal but I'm
not sure on how to properly configure this. Is what I'm trying to do
possible?
Can historical management be simulated with a SVN?
Can historical management be simulated with a SVN?
Introduction:
Hello, basically what i need to do is to simulate historical management
(in the terms of DB historical management) for a set of files, containing
compilable and executable pieces of code.
Explanations:
In DB historical management an object consists of its states, which are
determined by the dates of the actual modification. Then the object can be
fetched at given date along with the information that is current for that
given date. This is the behavior that I am trying to implement for the
files that I am going to execute. Since the most natural way of persisting
the project files is via a SVN product, It crossed my mind that it may be
possible that such feature is already implemented in Subversion or other
Version Control System. What i need is - by a given date and may be a
request to the svn server, to receive the "right" version (according to
the date) of the document that I am keeping track to.
The question:
Currently I am using Subversion and TortoiseSVN, but I am not familiar
with the advanced featured and seek some help here. Can I retrieve a file
version stored within my SVN from my java code?
Any help will be appreciated, Regards,
Milen
Introduction:
Hello, basically what i need to do is to simulate historical management
(in the terms of DB historical management) for a set of files, containing
compilable and executable pieces of code.
Explanations:
In DB historical management an object consists of its states, which are
determined by the dates of the actual modification. Then the object can be
fetched at given date along with the information that is current for that
given date. This is the behavior that I am trying to implement for the
files that I am going to execute. Since the most natural way of persisting
the project files is via a SVN product, It crossed my mind that it may be
possible that such feature is already implemented in Subversion or other
Version Control System. What i need is - by a given date and may be a
request to the svn server, to receive the "right" version (according to
the date) of the document that I am keeping track to.
The question:
Currently I am using Subversion and TortoiseSVN, but I am not familiar
with the advanced featured and seek some help here. Can I retrieve a file
version stored within my SVN from my java code?
Any help will be appreciated, Regards,
Milen
Tuesday, 1 October 2013
How do I find INSERT_PATH_TO_JSON_CONFIG_PATH
How do I find INSERT_PATH_TO_JSON_CONFIG_PATH
I am trying to set up a dropbox API on my php website.
It requires that I specify "INSERT_PATH_TO_JSON_CONFIG_PATH"
I have absolutely no idea how to find it.
Any tips would be appreciated.
I am trying to set up a dropbox API on my php website.
It requires that I specify "INSERT_PATH_TO_JSON_CONFIG_PATH"
I have absolutely no idea how to find it.
Any tips would be appreciated.
How to use variable inside parameter $_GET? example: ($_GET[$my_var])
How to use variable inside parameter $_GET? example: ($_GET[$my_var])
I'm developing a plugin for wordpress, the parameter of the $ _GET is
recorded in the database according to the preference of the User via the
Wordpress Admin Panel. The following validation has to be via the $ _GET,
this is the function:
$db_url = get_option('my_get_url');
// returns the value of the database entered by User
// on this case return --> page=nosupport
$url_explode = explode("=", $db_url);
$url_before = $url_explode[0]; // --> page
$url_after = $url_explode[1]; // --> nosupport
echo "Before: ".$url_before; // here are ok, return --> page
echo "After: ".$url_after; // here are ok, return --> nosupport
My problem is here:
// here $_GET no have any value, dont work on validate...
if($_GET[$url_before] != ""){
if($_GET['$url_before']=="nosupport"){
// my function goes here...
}
}
I using for test the parameter:
echo $_GET[$url_before];
But dont return any value...
I'm developing a plugin for wordpress, the parameter of the $ _GET is
recorded in the database according to the preference of the User via the
Wordpress Admin Panel. The following validation has to be via the $ _GET,
this is the function:
$db_url = get_option('my_get_url');
// returns the value of the database entered by User
// on this case return --> page=nosupport
$url_explode = explode("=", $db_url);
$url_before = $url_explode[0]; // --> page
$url_after = $url_explode[1]; // --> nosupport
echo "Before: ".$url_before; // here are ok, return --> page
echo "After: ".$url_after; // here are ok, return --> nosupport
My problem is here:
// here $_GET no have any value, dont work on validate...
if($_GET[$url_before] != ""){
if($_GET['$url_before']=="nosupport"){
// my function goes here...
}
}
I using for test the parameter:
echo $_GET[$url_before];
But dont return any value...
Downloading contents of the web page
Downloading contents of the web page
I want to write a python program to download the contents of a web page,
and then download the contents of the web pages that the first page links
to.
For example, this is main web page http://www.adobe.com/support/security/,
and the pages I want to download:
http://www.adobe.com/support/security/bulletins/apsb13-23.html and
http://www.adobe.com/support/security/bulletins/apsb13-22.html
There is a certain condition I want to meet: it should download only web
pages under bulletins not under
advisories(http://www.adobe.com/support/security/advisories/apsa13-02.html)
#!/usr/bin/env python
import urllib
import re
import sys
page = urllib.urlopen("http://www.adobe.com/support/security/")
page = page.read()
fileHandle = open('content', 'w')
links = re.findall(r"<a.*?\s*href=\"(.*?)\".*?>(.*?)</a>", page)
for link in links:
sys.stdout = fileHandle
print ('%s' % (link[0]))
sys.stdout = sys.__stdout__
fileHandle.close()
os.system("grep -i '\/support\/security\/bulletins\/' content >> content1")
I've already extracted the link of bulletins into a content1, but don't
know how to download the content of those web pages, by providing content1
as input.
The content1 file is as shown below:-
/support/security/bulletins/apsb13-23.html
/support/security/bulletins/apsb13-23.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-21.html
/support/security/bulletins/apsb13-21.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-15.html
/support/security/bulletins/apsb13-15.html
/support/security/bulletins/apsb13-07.html
I want to write a python program to download the contents of a web page,
and then download the contents of the web pages that the first page links
to.
For example, this is main web page http://www.adobe.com/support/security/,
and the pages I want to download:
http://www.adobe.com/support/security/bulletins/apsb13-23.html and
http://www.adobe.com/support/security/bulletins/apsb13-22.html
There is a certain condition I want to meet: it should download only web
pages under bulletins not under
advisories(http://www.adobe.com/support/security/advisories/apsa13-02.html)
#!/usr/bin/env python
import urllib
import re
import sys
page = urllib.urlopen("http://www.adobe.com/support/security/")
page = page.read()
fileHandle = open('content', 'w')
links = re.findall(r"<a.*?\s*href=\"(.*?)\".*?>(.*?)</a>", page)
for link in links:
sys.stdout = fileHandle
print ('%s' % (link[0]))
sys.stdout = sys.__stdout__
fileHandle.close()
os.system("grep -i '\/support\/security\/bulletins\/' content >> content1")
I've already extracted the link of bulletins into a content1, but don't
know how to download the content of those web pages, by providing content1
as input.
The content1 file is as shown below:-
/support/security/bulletins/apsb13-23.html
/support/security/bulletins/apsb13-23.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-21.html
/support/security/bulletins/apsb13-21.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-22.html
/support/security/bulletins/apsb13-15.html
/support/security/bulletins/apsb13-15.html
/support/security/bulletins/apsb13-07.html
How can I tell if a TCP port is open or not=?iso-8859-1?Q?=3F_=96_unix.stackexchange.com?=
How can I tell if a TCP port is open or not? – unix.stackexchange.com
I am trying to implement socket programming in C. When I try to connect
from a client to a server (Ubuntu), it shows an error like "connection
failed". So I think the problem is with the port. I am …
I am trying to implement socket programming in C. When I try to connect
from a client to a server (Ubuntu), it shows an error like "connection
failed". So I think the problem is with the port. I am …
Monday, 30 September 2013
Installing with source and package
Installing with source and package
I recently installed mysql and apache from source, and php using apt-get.
I wanted to install php with source, so I removed php package but
accidentally removed packages named "mysql-common apache2.2-common etc..."
I don't remember installing any of those packages. The only thing I did
after installing ubuntu on my desktop is installing mysql, apache with
source.
My question is: Does ubuntu recognize installed-from-source programs as
packages??
I recently installed mysql and apache from source, and php using apt-get.
I wanted to install php with source, so I removed php package but
accidentally removed packages named "mysql-common apache2.2-common etc..."
I don't remember installing any of those packages. The only thing I did
after installing ubuntu on my desktop is installing mysql, apache with
source.
My question is: Does ubuntu recognize installed-from-source programs as
packages??
Can't install rvm
Can't install rvm
I want to install RVM:
ubuntu@ext:~$ rvm
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
ubuntu@ext:~$ sudo apt-get install ruby-rvm
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ruby-rvm
How can I do it?
I want to install RVM:
ubuntu@ext:~$ rvm
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
ubuntu@ext:~$ sudo apt-get install ruby-rvm
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ruby-rvm
How can I do it?
Python in Maya - Query checkbox value
Python in Maya - Query checkbox value
Im super new to python and i have this little spare time project going on.
And i cant find a solution to the following problem:
I set up a GUI like this:
flWin = mc.window(title="Foot Locker", wh=(210,85))
mc.columnLayout()
mc.text(label='Frame Range')
rangeField = mc.intFieldGrp(numberOfFields=2,value1=0, value2=0)
mc.rowColumnLayout(numberOfRows=2)
translateBox = mc.checkBox(label='Translation',value=True)
mc.button(label="Bake it!", w=60, command="Bake()")
rotateBox = mc.checkBox(label='Rotation',value=True)
mc.button(label='Key it!', w=60, command='Key()')
scaleBox = mc.checkBox(label='Scale')
mc.showWindow(flWin)
and then later, inside the function 'Bake' id like to query the checkboxes
to do different stuff, depending on what boxes are checked... like this:
translateValue = mc.checkBox(translateBox, query=True)
rotateValue = mc.checkBox(rotateBox, query=True)
scaleValue = mc.checkBox(scaleBox, query=True)
if scaleValue = True:
if rotateValue = True:
if translateValue = True:
mc.parentConstraint ('LockCator', Selection,
n='LockCatorConstraint')
mc.scaleConstraint('LockCator', Selection,
n='selectionScale')
else:
mc.parentConstraint ('LockCator', Selection,
n='LockCatorConstraint', skipTranslate=True)
mc.scaleConstraint('LockCator', Selection, n='selectionScale')
bla bla bla... you get the trick...
when i try to run the script, i get a error saying that there is invalid
syntax on the line if scaleValue = True:
i also tried using this:
mc.attributeQuery(translateBox,value=True)
but that gives me an error, saying that 'value' is an invalid flag... i
dont know what that means.
Some help here would be greatly appreciated!! Thanks guys!
Im super new to python and i have this little spare time project going on.
And i cant find a solution to the following problem:
I set up a GUI like this:
flWin = mc.window(title="Foot Locker", wh=(210,85))
mc.columnLayout()
mc.text(label='Frame Range')
rangeField = mc.intFieldGrp(numberOfFields=2,value1=0, value2=0)
mc.rowColumnLayout(numberOfRows=2)
translateBox = mc.checkBox(label='Translation',value=True)
mc.button(label="Bake it!", w=60, command="Bake()")
rotateBox = mc.checkBox(label='Rotation',value=True)
mc.button(label='Key it!', w=60, command='Key()')
scaleBox = mc.checkBox(label='Scale')
mc.showWindow(flWin)
and then later, inside the function 'Bake' id like to query the checkboxes
to do different stuff, depending on what boxes are checked... like this:
translateValue = mc.checkBox(translateBox, query=True)
rotateValue = mc.checkBox(rotateBox, query=True)
scaleValue = mc.checkBox(scaleBox, query=True)
if scaleValue = True:
if rotateValue = True:
if translateValue = True:
mc.parentConstraint ('LockCator', Selection,
n='LockCatorConstraint')
mc.scaleConstraint('LockCator', Selection,
n='selectionScale')
else:
mc.parentConstraint ('LockCator', Selection,
n='LockCatorConstraint', skipTranslate=True)
mc.scaleConstraint('LockCator', Selection, n='selectionScale')
bla bla bla... you get the trick...
when i try to run the script, i get a error saying that there is invalid
syntax on the line if scaleValue = True:
i also tried using this:
mc.attributeQuery(translateBox,value=True)
but that gives me an error, saying that 'value' is an invalid flag... i
dont know what that means.
Some help here would be greatly appreciated!! Thanks guys!
how to handle two separate aggregate roots holding reference to same data?
how to handle two separate aggregate roots holding reference to same data?
In a domain model that models sports events how should this scenario be
handled, especially in the context of using a no sql document database to
hold the data.
The main entities in the system are Season, Tournament Group, Tournament,
Tournament-Stage, Match, Player.
Season - A Season has a start date, end date, an ordered collection of
Player and a collection of Tournament.
Tournament Group - A tournament group contains a collection of tournament,
each tournament can only belong to one tournament group. I am unsure if
this should actually be an entity.
Tournament - A Tournament has a start date, end date, an ordered
collection of Player and an ordered collection of Tournament-Stage.
Tournament-Stage - A Tournament-Stage has an ordered collection of Match.
Not sure if this should be an entity as its just a way to group matches
with in a Tournament.
Match - A Match contains a collection of Player.
This is where it gets confusing for me be because I would say so far that
the aggregate root is the Season but there will be I don't know where the
Player fits into this model and I'm probably not dealing with tournament
group properly either.
Statistics need to be generated to for a Season, Tournament Group and
Player e.g. Who scored the most in a Season, Who scored the most in a
Tournament Group and for a Player which Tournament, Season or Tournament
Group he scored most in.
To get this data I would have thought that the Player entity would have to
hold references to Tournament and Match but these references are also help
by Season. Is this acceptable and what is the best strategy for updating
the data in one aggregate root if it changes in another ?
In a domain model that models sports events how should this scenario be
handled, especially in the context of using a no sql document database to
hold the data.
The main entities in the system are Season, Tournament Group, Tournament,
Tournament-Stage, Match, Player.
Season - A Season has a start date, end date, an ordered collection of
Player and a collection of Tournament.
Tournament Group - A tournament group contains a collection of tournament,
each tournament can only belong to one tournament group. I am unsure if
this should actually be an entity.
Tournament - A Tournament has a start date, end date, an ordered
collection of Player and an ordered collection of Tournament-Stage.
Tournament-Stage - A Tournament-Stage has an ordered collection of Match.
Not sure if this should be an entity as its just a way to group matches
with in a Tournament.
Match - A Match contains a collection of Player.
This is where it gets confusing for me be because I would say so far that
the aggregate root is the Season but there will be I don't know where the
Player fits into this model and I'm probably not dealing with tournament
group properly either.
Statistics need to be generated to for a Season, Tournament Group and
Player e.g. Who scored the most in a Season, Who scored the most in a
Tournament Group and for a Player which Tournament, Season or Tournament
Group he scored most in.
To get this data I would have thought that the Player entity would have to
hold references to Tournament and Match but these references are also help
by Season. Is this acceptable and what is the best strategy for updating
the data in one aggregate root if it changes in another ?
Sunday, 29 September 2013
HeIp w/ this code
HeIp w/ this code
I wrote a program which tells me how many times words are found in the
column from top to bottom direction.
For eg.
STACK
OVER
FLOW
('STACK\OVER\FLOW', 'TVL') will return 1
So how do I change the code so it also search the words in bottom to top
direction.
I wrote a program which tells me how many times words are found in the
column from top to bottom direction.
For eg.
STACK
OVER
FLOW
('STACK\OVER\FLOW', 'TVL') will return 1
So how do I change the code so it also search the words in bottom to top
direction.
Find strings in a large file and write each one to a second file in Python
Find strings in a large file and write each one to a second file in Python
I'm new to Python (And programming generally). To make a work project
easier, I am trying to write some code that searches an XML file for
certain tags and copies the contents to a second file. The file I need to
read from is about 165MB, and will have 10s of thousands of entries to
pull out.
I have successfully made it work for small files (Working from example
code on forums such as this one), but it falls apart above a certain size
(It starts copying large portions of the XML, instead of just the required
strings). I imagine this is because of how I have defined my variables.
Can someone give me a pointer or sample code, to fix this? I'm surprised
it works as far as it does!
This is the code I have now:
text = open("UPC_Small.xml", "r")
lines = text.read()
fo = open("output.log", "wt")
crid1 = 0
while True:
crid1 = lines.find('<ProgramInformation programId="crid://bds.tv/',crid1)
crid2 = lines.find('">',crid1)
crid_string = (lines[crid1+45:crid2])
if crid1 == -1:
fo.write("End of File")
fo.close()
break
title1 = lines.find('<Title xml:lang="EN" type="main">',crid2)
title2 = lines.find('</Title>',title1)
title_string = (lines[title1+33:title2])
genre1 = lines.find('<Name xml:lang="EN">',title2)
genre2 = lines.find('</Name>',genre1)
genre_string = (lines[genre1+20:genre2])
fo.write(crid_string + "|" + title_string + "|" + genre_string + "\n")
I'm new to Python (And programming generally). To make a work project
easier, I am trying to write some code that searches an XML file for
certain tags and copies the contents to a second file. The file I need to
read from is about 165MB, and will have 10s of thousands of entries to
pull out.
I have successfully made it work for small files (Working from example
code on forums such as this one), but it falls apart above a certain size
(It starts copying large portions of the XML, instead of just the required
strings). I imagine this is because of how I have defined my variables.
Can someone give me a pointer or sample code, to fix this? I'm surprised
it works as far as it does!
This is the code I have now:
text = open("UPC_Small.xml", "r")
lines = text.read()
fo = open("output.log", "wt")
crid1 = 0
while True:
crid1 = lines.find('<ProgramInformation programId="crid://bds.tv/',crid1)
crid2 = lines.find('">',crid1)
crid_string = (lines[crid1+45:crid2])
if crid1 == -1:
fo.write("End of File")
fo.close()
break
title1 = lines.find('<Title xml:lang="EN" type="main">',crid2)
title2 = lines.find('</Title>',title1)
title_string = (lines[title1+33:title2])
genre1 = lines.find('<Name xml:lang="EN">',title2)
genre2 = lines.find('</Name>',genre1)
genre_string = (lines[genre1+20:genre2])
fo.write(crid_string + "|" + title_string + "|" + genre_string + "\n")
Running multipule comands in batch at the same time?
Running multipule comands in batch at the same time?
I'm trying to get a batch equivalent of '&' from shell.
curl --referer http://fs1d-h.st/cxX -o ~/Library/Application\
Support/download.part1 $url1 &
curl --referer http://fs1d-h.st/1w9 -o ~/Library/Application\
Support/download.part2 $url2
The first curl command executes in the background, and then runs the
second one immediately after the first is started. The result is two
downloads (or other commands) running at the same time.
I've looked around and I can seem to find a way to do this in windows cmd.
Any ideas?
I'm trying to get a batch equivalent of '&' from shell.
curl --referer http://fs1d-h.st/cxX -o ~/Library/Application\
Support/download.part1 $url1 &
curl --referer http://fs1d-h.st/1w9 -o ~/Library/Application\
Support/download.part2 $url2
The first curl command executes in the background, and then runs the
second one immediately after the first is started. The result is two
downloads (or other commands) running at the same time.
I've looked around and I can seem to find a way to do this in windows cmd.
Any ideas?
how to trim css code to just one line
how to trim css code to just one line
My client is fussy about his website loading speed. I think one way is to
trim css code to just one line. For example:
tr th{
border-bottom: 1px solid;
text-align: left;
}
tr th, tr td{
padding: 9px 20px;
border-right: 1px solid;
}
to
tr th{border-bottom: 1px solid;text-align: left;}tr th, tr td{padding: 9px
20px;border-right: 1px solid;}
How do you guys normal trim it? I use dreamweaver to write css code.
Also, I found Youtube's css link is like
"http://s.ytimg.com/yts/cssbin/www-home-c4-2x-vflt3qrMn.css", is there
benefits? Cheers.
My client is fussy about his website loading speed. I think one way is to
trim css code to just one line. For example:
tr th{
border-bottom: 1px solid;
text-align: left;
}
tr th, tr td{
padding: 9px 20px;
border-right: 1px solid;
}
to
tr th{border-bottom: 1px solid;text-align: left;}tr th, tr td{padding: 9px
20px;border-right: 1px solid;}
How do you guys normal trim it? I use dreamweaver to write css code.
Also, I found Youtube's css link is like
"http://s.ytimg.com/yts/cssbin/www-home-c4-2x-vflt3qrMn.css", is there
benefits? Cheers.
Saturday, 28 September 2013
if else using the next unique value in column by key
if else using the next unique value in column by key
I have a question. How do I perform the following operations on the
sampdata object? The result that I would like to have is the sampres
object.
Thank you.
Pseudocode:
if sampdata[,flow[1] == flow[2], by = site_no]
sampdata[,flow[2]] = next unique flow value # if yes
no change # if no
Starting data:
library(data.table)
sampdata <-
data.table(c(02446500,02446500,02446500,02467000,02467000,02467000,06818000,06818000,06818000,06818000,06893000,06893000,06893000,06893000,06934500,06934500,06934500,07010000,07010000,07010000,07289000,07289000,07289000),c(21,21,22,70,76,82,14700,14700,14700,14800,11000,11000,11000,11100,19400,19400,19500,32000,32000,32100,146000,146000,147000),c(4,4.01,4.02,73.05,73.06,73.07,1,1.01,1.02,1.03,1,1.01,1.02,1.03,-1.2,-1.19,-1.18,-9.02,-9.01,-9,-4.43,-4.42,-4.41))
setnames(sampdata,c("site_no", "flow", "gage"))
setkey(sampdata, site_no)
End result:
sampres <-
data.table(c(02446500,02446500,02446500,02467000,02467000,02467000,06818000,06818000,06818000,06818000,06893000,06893000,06893000,06893000,06934500,06934500,06934500,07010000,07010000,07010000,07289000,07289000,07289000),c(21,22,22,70,76,82,14700,14800,14700,14800,11000,11100,11000,11100,19400,19500,19500,32000,32100,32100,146000,147000,147000),c(4,4.02,4.02,73.05,73.06,73.07,1,1.03,1.02,1.03,1,1.03,1.02,1.03,-1.2,-1.18,-1.18,-9.02,-9,-9,-4.43,-4.41,-4.41))
setnames(sampres,c("site_no", "flow", "gage"))
setkey(sampres, site_no)
To clarify, here are the initial data and result side-by-side, from
cbind(sampdata,sampres):
site_no flow gage site_no flow gage
1: 2446500 21 4.00 2446500 21 4.00
2: 2446500 21 4.01 2446500 22 4.02
3: 2446500 22 4.02 2446500 22 4.02
4: 2467000 70 73.05 2467000 70 73.05
5: 2467000 76 73.06 2467000 76 73.06
6: 2467000 82 73.07 2467000 82 73.07
7: 6818000 14700 1.00 6818000 14700 1.00
8: 6818000 14700 1.01 6818000 14800 1.03
9: 6818000 14700 1.02 6818000 14700 1.02
10: 6818000 14800 1.03 6818000 14800 1.03
11: 6893000 11000 1.00 6893000 11000 1.00
12: 6893000 11000 1.01 6893000 11100 1.03
13: 6893000 11000 1.02 6893000 11000 1.02
14: 6893000 11100 1.03 6893000 11100 1.03
15: 6934500 19400 -1.20 6934500 19400 -1.20
16: 6934500 19400 -1.19 6934500 19500 -1.18
17: 6934500 19500 -1.18 6934500 19500 -1.18
18: 7010000 32000 -9.02 7010000 32000 -9.02
19: 7010000 32000 -9.01 7010000 32100 -9.00
20: 7010000 32100 -9.00 7010000 32100 -9.00
21: 7289000 146000 -4.43 7289000 146000 -4.43
22: 7289000 146000 -4.42 7289000 147000 -4.41
23: 7289000 147000 -4.41 7289000 147000 -4.41
site_no flow gage site_no flow gage
I have a question. How do I perform the following operations on the
sampdata object? The result that I would like to have is the sampres
object.
Thank you.
Pseudocode:
if sampdata[,flow[1] == flow[2], by = site_no]
sampdata[,flow[2]] = next unique flow value # if yes
no change # if no
Starting data:
library(data.table)
sampdata <-
data.table(c(02446500,02446500,02446500,02467000,02467000,02467000,06818000,06818000,06818000,06818000,06893000,06893000,06893000,06893000,06934500,06934500,06934500,07010000,07010000,07010000,07289000,07289000,07289000),c(21,21,22,70,76,82,14700,14700,14700,14800,11000,11000,11000,11100,19400,19400,19500,32000,32000,32100,146000,146000,147000),c(4,4.01,4.02,73.05,73.06,73.07,1,1.01,1.02,1.03,1,1.01,1.02,1.03,-1.2,-1.19,-1.18,-9.02,-9.01,-9,-4.43,-4.42,-4.41))
setnames(sampdata,c("site_no", "flow", "gage"))
setkey(sampdata, site_no)
End result:
sampres <-
data.table(c(02446500,02446500,02446500,02467000,02467000,02467000,06818000,06818000,06818000,06818000,06893000,06893000,06893000,06893000,06934500,06934500,06934500,07010000,07010000,07010000,07289000,07289000,07289000),c(21,22,22,70,76,82,14700,14800,14700,14800,11000,11100,11000,11100,19400,19500,19500,32000,32100,32100,146000,147000,147000),c(4,4.02,4.02,73.05,73.06,73.07,1,1.03,1.02,1.03,1,1.03,1.02,1.03,-1.2,-1.18,-1.18,-9.02,-9,-9,-4.43,-4.41,-4.41))
setnames(sampres,c("site_no", "flow", "gage"))
setkey(sampres, site_no)
To clarify, here are the initial data and result side-by-side, from
cbind(sampdata,sampres):
site_no flow gage site_no flow gage
1: 2446500 21 4.00 2446500 21 4.00
2: 2446500 21 4.01 2446500 22 4.02
3: 2446500 22 4.02 2446500 22 4.02
4: 2467000 70 73.05 2467000 70 73.05
5: 2467000 76 73.06 2467000 76 73.06
6: 2467000 82 73.07 2467000 82 73.07
7: 6818000 14700 1.00 6818000 14700 1.00
8: 6818000 14700 1.01 6818000 14800 1.03
9: 6818000 14700 1.02 6818000 14700 1.02
10: 6818000 14800 1.03 6818000 14800 1.03
11: 6893000 11000 1.00 6893000 11000 1.00
12: 6893000 11000 1.01 6893000 11100 1.03
13: 6893000 11000 1.02 6893000 11000 1.02
14: 6893000 11100 1.03 6893000 11100 1.03
15: 6934500 19400 -1.20 6934500 19400 -1.20
16: 6934500 19400 -1.19 6934500 19500 -1.18
17: 6934500 19500 -1.18 6934500 19500 -1.18
18: 7010000 32000 -9.02 7010000 32000 -9.02
19: 7010000 32000 -9.01 7010000 32100 -9.00
20: 7010000 32100 -9.00 7010000 32100 -9.00
21: 7289000 146000 -4.43 7289000 146000 -4.43
22: 7289000 146000 -4.42 7289000 147000 -4.41
23: 7289000 147000 -4.41 7289000 147000 -4.41
site_no flow gage site_no flow gage
Replacing a While loop with AutoResetEvent for blocking a thread
Replacing a While loop with AutoResetEvent for blocking a thread
Recently, I was finally able to make a separate thread work. Now I am
trying to master synchronization.
As far as I know, pausing a thread with ThreadName.Suspend() is not a good
idea. At fist I used a While loop to block the thread. Later I noticed
that this consumes resources, so now I am trying to replace the loop with
an AutoResetEvent.
Here is some code (tell me if you the full code):
private void combTester(object sender, EventArgs e)
//happens in a timer, because it manipulates the GUI
{
if (!timer2Block)
{
//stuff happens
genBlock = false;//unblocks the thread
timer2Block = true;//blocks itself
//debugging stuff happens
}
if (done)
timer2.Enabled = false;
}
private void combGenerator(int currEl, int begVal)
{
//setting a variable
for (int c = begVal; c <= currEl + totalCells - maxCells; c++)
{
while (genBlock && !abortTime)
{
if (abortTime)
return;
}
genBlock = true;//blocks itself
//some recursive stuff happens,
//because of which I was forced to use a thread instead of timers
}
}
I tried different places to put the Wait() and Set() methods, but both the
tread and the timer get blocked and I don't know how to debug the program.
So, how can I replace the While loop with AutoResetEvent?
Recently, I was finally able to make a separate thread work. Now I am
trying to master synchronization.
As far as I know, pausing a thread with ThreadName.Suspend() is not a good
idea. At fist I used a While loop to block the thread. Later I noticed
that this consumes resources, so now I am trying to replace the loop with
an AutoResetEvent.
Here is some code (tell me if you the full code):
private void combTester(object sender, EventArgs e)
//happens in a timer, because it manipulates the GUI
{
if (!timer2Block)
{
//stuff happens
genBlock = false;//unblocks the thread
timer2Block = true;//blocks itself
//debugging stuff happens
}
if (done)
timer2.Enabled = false;
}
private void combGenerator(int currEl, int begVal)
{
//setting a variable
for (int c = begVal; c <= currEl + totalCells - maxCells; c++)
{
while (genBlock && !abortTime)
{
if (abortTime)
return;
}
genBlock = true;//blocks itself
//some recursive stuff happens,
//because of which I was forced to use a thread instead of timers
}
}
I tried different places to put the Wait() and Set() methods, but both the
tread and the timer get blocked and I don't know how to debug the program.
So, how can I replace the While loop with AutoResetEvent?
Return array in php
Return array in php
So, I'm filling an array with data from a database using a query. I want
to know what is the correct way to return the whole array. Note that the
code has been edited to ask this specific question, so it may have syntax
or other errors. I only want to know if im returning the array correctly.
Thanks!
function getDailyGraph($membership, $selectedMonth){
$sql = "SELECT rate_amount AS payment, DAY(date) AS day FROM
payments WHERE membership_id = ".$membership.
" AND MONTH(date) = ".$selectedMonth." ORDER BY day";
$query = $db->query($sql);
$days = array();
while ($payment = mysql_fetch_array($query)) {
$days[] = $payment['payment'];
}
return $days;
}
This is how i call the function:
$daily = $member->getDailyGraph(4,9);
The function code is inside class Members instanced as $member.
So, I'm filling an array with data from a database using a query. I want
to know what is the correct way to return the whole array. Note that the
code has been edited to ask this specific question, so it may have syntax
or other errors. I only want to know if im returning the array correctly.
Thanks!
function getDailyGraph($membership, $selectedMonth){
$sql = "SELECT rate_amount AS payment, DAY(date) AS day FROM
payments WHERE membership_id = ".$membership.
" AND MONTH(date) = ".$selectedMonth." ORDER BY day";
$query = $db->query($sql);
$days = array();
while ($payment = mysql_fetch_array($query)) {
$days[] = $payment['payment'];
}
return $days;
}
This is how i call the function:
$daily = $member->getDailyGraph(4,9);
The function code is inside class Members instanced as $member.
Performance Issue in Executing Shell Commands
Performance Issue in Executing Shell Commands
In my application, I need to execute large amount of shell commands via
c++ code. I found the program takes more than 30 seconds to execute 6000
commands, this is so unacceptable! Is there any other better way to
execute shell commands (using c/c++ code)?
//Below functions is used to set rules for
//Linux tool --TC, and in runtime there will
//be more than 6000 rules to be set from shell
void CTCProxy::ApplyTCCommands(){
FILE* OutputStream = NULL;
//mTCCommands is a vector<string>
//every string in it is a TC rule
int CmdCount = mTCCommands.size();
for (int i = 0; i < CmdCount; i++){
OutputStream = popen(mTCCommands[i].c_str(), "r");
if (OutputStream){
pclose(OutputStream);
} else {
printf("popen error!\n");
}
}
}
In my application, I need to execute large amount of shell commands via
c++ code. I found the program takes more than 30 seconds to execute 6000
commands, this is so unacceptable! Is there any other better way to
execute shell commands (using c/c++ code)?
//Below functions is used to set rules for
//Linux tool --TC, and in runtime there will
//be more than 6000 rules to be set from shell
void CTCProxy::ApplyTCCommands(){
FILE* OutputStream = NULL;
//mTCCommands is a vector<string>
//every string in it is a TC rule
int CmdCount = mTCCommands.size();
for (int i = 0; i < CmdCount; i++){
OutputStream = popen(mTCCommands[i].c_str(), "r");
if (OutputStream){
pclose(OutputStream);
} else {
printf("popen error!\n");
}
}
}
Friday, 27 September 2013
Changing document title back with javascript
Changing document title back with javascript
So, I have some event which would change the document title using javascript.
$('.someclass').click(function(){
document.title = "Some new title";
});
Now that I've renamed the document title, how do I revert it back to what
it was originally? The text that actually appears between the <title> tags
in the html document?
So, I have some event which would change the document title using javascript.
$('.someclass').click(function(){
document.title = "Some new title";
});
Now that I've renamed the document title, how do I revert it back to what
it was originally? The text that actually appears between the <title> tags
in the html document?
elasticsearch jdbc river polling--- load data from mysql repeatedly
elasticsearch jdbc river polling--- load data from mysql repeatedly
When using https://github.com/jprante/elasticsearch-river-jdbc I notice
that the following curl statement successfully indexes data the first
time. However, the river fails to repeatedly poll the database for
updates.
To restate, when I run the following, the river successfully connects to
MySQL, runs the query successfully, indexes the results, but never runs
the query again.
curl -XPUT '127.0.0.1:9200/_river/projects_river/_meta' -d '{
"type" : "jdbc",
"index" : {
"index" : "test_projects",
"type" : "project",
"bulk_size" : 100,
"max_bulk_requests" : 1,
"autocommit": true
},
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"poll" : "1m",
"strategy" : "simple",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "root",
"sql" : "SELECT name, updated_at from projects p where p.updated_at >
date_sub(now(),interval 1 minute)"
}
}'
Tailing the log, I see: [2013-09-27 16:32:24,482][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:33:24,488][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:34:24,494][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:35:24,499][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:36:24,504][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:37:24,509][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:38:24,512][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:39:24,516][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m
But the index stays empty. Running on a macbook pro with elasticsearch
version stable 0.90.2, HEAD and mysql-connector-java-5.1.25-bin.jar in the
river pligns directory.
When using https://github.com/jprante/elasticsearch-river-jdbc I notice
that the following curl statement successfully indexes data the first
time. However, the river fails to repeatedly poll the database for
updates.
To restate, when I run the following, the river successfully connects to
MySQL, runs the query successfully, indexes the results, but never runs
the query again.
curl -XPUT '127.0.0.1:9200/_river/projects_river/_meta' -d '{
"type" : "jdbc",
"index" : {
"index" : "test_projects",
"type" : "project",
"bulk_size" : 100,
"max_bulk_requests" : 1,
"autocommit": true
},
"jdbc" : {
"driver" : "com.mysql.jdbc.Driver",
"poll" : "1m",
"strategy" : "simple",
"url" : "jdbc:mysql://localhost:3306/test",
"user" : "root",
"sql" : "SELECT name, updated_at from projects p where p.updated_at >
date_sub(now(),interval 1 minute)"
}
}'
Tailing the log, I see: [2013-09-27 16:32:24,482][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:33:24,488][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:34:24,494][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:35:24,499][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:36:24,504][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:37:24,509][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:38:24,512][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m [2013-09-27 16:39:24,516][INFO
][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverFlow] next run,
waiting 1m
But the index stays empty. Running on a macbook pro with elasticsearch
version stable 0.90.2, HEAD and mysql-connector-java-5.1.25-bin.jar in the
river pligns directory.
Androind custom spinner doesn't show the dropdown arrow
Androind custom spinner doesn't show the dropdown arrow
http://www.coderzheaven.com/2011/07/18/customizing-a-spinner-in-android/
In this example before an item is selected it shows text and dropdown
arrow on the right. When they user clicks it (displaymode = dropdown?) it
shows the prompt with an arrow.
I do not have android theme on my app. I have custom spinner like so:
List<LanguageSelection> nativeLanguagesData =
getSupportedLanguageList();
LanguageSelectionListAdapter nativeAdapter = new
LanguageSelectionListAdapter (this,
R.layout.fragment_language_selection, nativeLanguagesData);
nativeAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
Spinner uxNativeLanguageSpinner =
(Spinner)findViewById(R.id.uxNativeLanguageSpinner);
uxNativeLanguageSpinner.setAdapter(nativeAdapter);
and for xml:
<Spinner android:id="@+id/uxNativeLanguageSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:padding="0dp"
android:spinnerMode="dropdown"
android:prompt="@string/status_prompt"
android:layout_below="@id/uxNativeLanguageSelectLabel"
android:popupBackground="@android:color/transparent" />
Attached is what actually appears. I've scoured the internet tryinig to
figure out why this thing doesn't show. I also have the android
simple_spinner_dropdown_item.xml in my code base instead of referencing
andorid.*. Any ideas? I'd like to get rid of my ugly label just above the
spinner indicating the user needs to select something and instead use the
common dropdown arrow. Just doesn't show when I create a custom spinner
though. Again, the items in the list appear correctly it's just that i
want the first item be something like in the link at the top where there
is Select and iten and icon to the right indicating it's dropdown.
//image removed as "i need at least 10 reputation points to post image".
Basically my spinner is custom spiiner with text on left and image on
right for each item in the list.
http://www.coderzheaven.com/2011/07/18/customizing-a-spinner-in-android/
In this example before an item is selected it shows text and dropdown
arrow on the right. When they user clicks it (displaymode = dropdown?) it
shows the prompt with an arrow.
I do not have android theme on my app. I have custom spinner like so:
List<LanguageSelection> nativeLanguagesData =
getSupportedLanguageList();
LanguageSelectionListAdapter nativeAdapter = new
LanguageSelectionListAdapter (this,
R.layout.fragment_language_selection, nativeLanguagesData);
nativeAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
Spinner uxNativeLanguageSpinner =
(Spinner)findViewById(R.id.uxNativeLanguageSpinner);
uxNativeLanguageSpinner.setAdapter(nativeAdapter);
and for xml:
<Spinner android:id="@+id/uxNativeLanguageSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:padding="0dp"
android:spinnerMode="dropdown"
android:prompt="@string/status_prompt"
android:layout_below="@id/uxNativeLanguageSelectLabel"
android:popupBackground="@android:color/transparent" />
Attached is what actually appears. I've scoured the internet tryinig to
figure out why this thing doesn't show. I also have the android
simple_spinner_dropdown_item.xml in my code base instead of referencing
andorid.*. Any ideas? I'd like to get rid of my ugly label just above the
spinner indicating the user needs to select something and instead use the
common dropdown arrow. Just doesn't show when I create a custom spinner
though. Again, the items in the list appear correctly it's just that i
want the first item be something like in the link at the top where there
is Select and iten and icon to the right indicating it's dropdown.
//image removed as "i need at least 10 reputation points to post image".
Basically my spinner is custom spiiner with text on left and image on
right for each item in the list.
git feature branch: rebase -i or merge --no-ff?
git feature branch: rebase -i or merge --no-ff?
Many git workflows advocate doing a git merge --no-ff to bring a feature
branch into the mainline. I personally prefer to git rebase -i my feature
branch into one clean commit, and then do a simple git merge of that.
Is there any downside to using rebase -i this way instead of merge --no-ff
for feature branches?
Many git workflows advocate doing a git merge --no-ff to bring a feature
branch into the mainline. I personally prefer to git rebase -i my feature
branch into one clean commit, and then do a simple git merge of that.
Is there any downside to using rebase -i this way instead of merge --no-ff
for feature branches?
jQuery: Exclude Checkbox with a specific value
jQuery: Exclude Checkbox with a specific value
How to exclude checkboxes like
<input type="checkbox" value="multiselect-all">
from
$(section).find('input, select').each(function(i, field) {});
I tried using
$(section).find('input:not(checkbox), select').each(function(i, field) {});
but it didn't work at the first place. So I could not proceed to filter
checkbox with a value.
How to exclude checkboxes like
<input type="checkbox" value="multiselect-all">
from
$(section).find('input, select').each(function(i, field) {});
I tried using
$(section).find('input:not(checkbox), select').each(function(i, field) {});
but it didn't work at the first place. So I could not proceed to filter
checkbox with a value.
How to change the current folder on Delphi?
How to change the current folder on Delphi?
How to change system current folder for the application on Delphi? Can't
find the similar question on the Stackoverflow.
How to change system current folder for the application on Delphi? Can't
find the similar question on the Stackoverflow.
Drupal 7 - Getting already loaded nodes
Drupal 7 - Getting already loaded nodes
Is it possible to access already loaded nodes within a region template?
This is to prevent re-querying the same thing twice. I know that I can
load nodes with nid using node_load, which if the node is already loaded
it will retrieve the node from static cache. But for this case I don't
know the nid so I prefer getting a list of nids already loaded.
PS: Using PDO results are cached so there won't be much performance drop
even though I query the same thing several times but still I prefer
minimizing database contact as much as possible.
Is it possible to access already loaded nodes within a region template?
This is to prevent re-querying the same thing twice. I know that I can
load nodes with nid using node_load, which if the node is already loaded
it will retrieve the node from static cache. But for this case I don't
know the nid so I prefer getting a list of nids already loaded.
PS: Using PDO results are cached so there won't be much performance drop
even though I query the same thing several times but still I prefer
minimizing database contact as much as possible.
Thursday, 26 September 2013
Toggle css property in jquery?
Toggle css property in jquery?
I have a menu that slides out on clicking the nav-toggle class.
Now I also want the nav-toggle class (the menu icon) to move along 226px
from the right, so it moves at the same time as the #navigation menu. Then
if clicked again it will collapse the menu (as it currently does) and go
back to right:0 position.
See my commenting out in the third last line
jQuery('.nav-toggle').click(function () {
var $marginLefty = jQuery('#navigation');
$marginLefty.animate({
right: parseInt($marginLefty.css('right'), 10) == 0 ?
-$marginLefty.outerWidth() : 0
});
jQuery('.nav-toggle').animate({
right: "226px"
// How do I make it so if it is at 226px when clicked
// it should then go to "right: 0", that toggle effect as above
});
});
I have a menu that slides out on clicking the nav-toggle class.
Now I also want the nav-toggle class (the menu icon) to move along 226px
from the right, so it moves at the same time as the #navigation menu. Then
if clicked again it will collapse the menu (as it currently does) and go
back to right:0 position.
See my commenting out in the third last line
jQuery('.nav-toggle').click(function () {
var $marginLefty = jQuery('#navigation');
$marginLefty.animate({
right: parseInt($marginLefty.css('right'), 10) == 0 ?
-$marginLefty.outerWidth() : 0
});
jQuery('.nav-toggle').animate({
right: "226px"
// How do I make it so if it is at 226px when clicked
// it should then go to "right: 0", that toggle effect as above
});
});
Wednesday, 25 September 2013
How to get DIVs with certain class and also without?
How to get DIVs with certain class and also without?
I've got this HTML:
<div class="hello top">some content</div>
<div class="hello top">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
... and i am trying to get only those DIVs which has class "hello" but not
class "top" (i want 3 last DIVs only to get).
I tried something like this but without success:
foreach( $html->find('div[class="hello"], div[class!="top"]') as $element ) {
// some code...
}
I've got this HTML:
<div class="hello top">some content</div>
<div class="hello top">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
<div class="hello">some content</div>
... and i am trying to get only those DIVs which has class "hello" but not
class "top" (i want 3 last DIVs only to get).
I tried something like this but without success:
foreach( $html->find('div[class="hello"], div[class!="top"]') as $element ) {
// some code...
}
Thursday, 19 September 2013
What can the programming language JAVA do?
What can the programming language JAVA do?
I will be taking a java class in October. I would like to know what the
programming language Java can and can't do. My teacher said it is
necessary for mobile development applications. What can Java do? And what
can't it do? What is it used for?
I will be taking a java class in October. I would like to know what the
programming language Java can and can't do. My teacher said it is
necessary for mobile development applications. What can Java do? And what
can't it do? What is it used for?
How can I check if a cell in Excel spreadsheet contains number
How can I check if a cell in Excel spreadsheet contains number
I have a column of addresses and I have to find those which don't contain
street numbers. Unfortunately, addresses have been input by various users
and they do not follow the same pattern so the street type, street name,
suburb are in different order and I can't use functions like LEFT, RIGHT
or MID to check if particular character is a number. The column looks like
this:
10 Willsons Drive, Manhattan
Epping, 23 Wet Rd
Longsdale St, Kingsbury
11 Link Crt, Pakenham
Is there an Excel or VBA function that can tell me if cell / string
contains numbers?
I have a column of addresses and I have to find those which don't contain
street numbers. Unfortunately, addresses have been input by various users
and they do not follow the same pattern so the street type, street name,
suburb are in different order and I can't use functions like LEFT, RIGHT
or MID to check if particular character is a number. The column looks like
this:
10 Willsons Drive, Manhattan
Epping, 23 Wet Rd
Longsdale St, Kingsbury
11 Link Crt, Pakenham
Is there an Excel or VBA function that can tell me if cell / string
contains numbers?
Service Stack - Cannot find any Mocks
Service Stack - Cannot find any Mocks
unless I'm missing it, I can't find any mocks in the code . I see some
integration tests, but no mocks on the github site for ServiceStack tests
unless I'm missing it, I can't find any mocks in the code . I see some
integration tests, but no mocks on the github site for ServiceStack tests
Why does a signed shift right bring in 1s instead of just holding a 1 in the most significant spot?
Why does a signed shift right bring in 1s instead of just holding a 1 in
the most significant spot?
...and bring in 0s.
For example:
1111 0110 >> 2
gives
11 1111 01
according to some notes.
Why are 1s brought in?
Isn't shifting to the right sort of like dividing by 2? If so shouldn't 0s
be brought in?
the most significant spot?
...and bring in 0s.
For example:
1111 0110 >> 2
gives
11 1111 01
according to some notes.
Why are 1s brought in?
Isn't shifting to the right sort of like dividing by 2? If so shouldn't 0s
be brought in?
Error with PKCS12KeyStore on porting an application from java 6 to java 7
Error with PKCS12KeyStore on porting an application from java 6 to java 7
I´m porting an application from java 6 to 7.
When I insert the login and password I get an IOException on PKCS12KeyStore.
I'm using it on a 64 bits system.
Is there some difference on this process between java 6 and 7?
If necessary, I can put the stacktrace here...
I´m porting an application from java 6 to 7.
When I insert the login and password I get an IOException on PKCS12KeyStore.
I'm using it on a 64 bits system.
Is there some difference on this process between java 6 and 7?
If necessary, I can put the stacktrace here...
No Content-type in the header! Error while trying to access my Web Service
No Content-type in the header! Error while trying to access my Web Service
I am working on a Web Service example on eclipse using the jboss 4.2
server. I have Created a service implementation class as below:
import java.util.HashMap;
import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class CarWebServiceImpl {
private final Map<String, Integer> prices = new HashMap<String,
Integer>();
public CarWebServiceImpl() {
prices.put("audi", Integer.valueOf(10000));
prices.put("bmw", Integer.valueOf(150000));
prices.put("fiat", Integer.valueOf(5000));
}
@WebMethod
public Response getCarPrice(String carId) {
int price = prices.get(carId);
Response resp = new Response();
resp.setPrice(price);
return resp;
}
}
The Web Service is automatically deployed into the server and i can see my
service at
http://127.0.0.1:8080/jbossws/services/
I have created another project and have use the wsconsume utility to
generate the client side class file. Then I instantiated the service class
as follow:
public class Client {
public static void main(String[] args) {
CarWebServiceImplService service = new CarWebServiceImplService();
CarWebServiceImpl port = service.getCarWebServiceImplPort();
port.getCarPrice("audi");
}
}
But when i am trying to run client code I am getting the following error
Exception in thread "main" javax.xml.ws.WebServiceException: No
Content-type in the header!
at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:172)
at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
at
com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy25.getCarPrice(Unknown Source)
at wsclient.Client.main(Client.java:7)
I don't know what is wrong with my approach. Please help. Thanks in advance.
I am working on a Web Service example on eclipse using the jboss 4.2
server. I have Created a service implementation class as below:
import java.util.HashMap;
import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class CarWebServiceImpl {
private final Map<String, Integer> prices = new HashMap<String,
Integer>();
public CarWebServiceImpl() {
prices.put("audi", Integer.valueOf(10000));
prices.put("bmw", Integer.valueOf(150000));
prices.put("fiat", Integer.valueOf(5000));
}
@WebMethod
public Response getCarPrice(String carId) {
int price = prices.get(carId);
Response resp = new Response();
resp.setPrice(price);
return resp;
}
}
The Web Service is automatically deployed into the server and i can see my
service at
http://127.0.0.1:8080/jbossws/services/
I have created another project and have use the wsconsume utility to
generate the client side class file. Then I instantiated the service class
as follow:
public class Client {
public static void main(String[] args) {
CarWebServiceImplService service = new CarWebServiceImplService();
CarWebServiceImpl port = service.getCarWebServiceImplPort();
port.getCarPrice("audi");
}
}
But when i am trying to run client code I am getting the following error
Exception in thread "main" javax.xml.ws.WebServiceException: No
Content-type in the header!
at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:172)
at
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
at
com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy25.getCarPrice(Unknown Source)
at wsclient.Client.main(Client.java:7)
I don't know what is wrong with my approach. Please help. Thanks in advance.
Ue both ormlite and robojuice in activity
Ue both ormlite and robojuice in activity
I would like to use both robojuice & ormlite.
If I want to use ormlite my Activity have to extend OrmLiteBaseActivity
and for robojuice it should extend RoboActivity.
What is the best practice to mix them ?
I would like to use both robojuice & ormlite.
If I want to use ormlite my Activity have to extend OrmLiteBaseActivity
and for robojuice it should extend RoboActivity.
What is the best practice to mix them ?
Wednesday, 18 September 2013
Redirect from /folder/index.php to /folder/
Redirect from /folder/index.php to /folder/
I am trying to get my website to redirect to
www.domain.tld/folder/
from
www.domain.tld/folder/index.php?params=blah¶m2=etc
I have tried:
header("Location: /")
But all it does is redirect me to
www.domain.tld
Does anyone know how to redirect properly to just the folder?
I am trying to get my website to redirect to
www.domain.tld/folder/
from
www.domain.tld/folder/index.php?params=blah¶m2=etc
I have tried:
header("Location: /")
But all it does is redirect me to
www.domain.tld
Does anyone know how to redirect properly to just the folder?
java struts application compatible with IE 8
java struts application compatible with IE 8
I developed an application in struts, its not compatible with Internet
explorer. I made compatibility view in IE 9 and it works, but in my
company some people uses IE 8, so they need to work with it on IE 8 only.
Please help how to make java struts application compatible with IE 8
Please help, any kind of help would be appreciated.
Thanks
I developed an application in struts, its not compatible with Internet
explorer. I made compatibility view in IE 9 and it works, but in my
company some people uses IE 8, so they need to work with it on IE 8 only.
Please help how to make java struts application compatible with IE 8
Please help, any kind of help would be appreciated.
Thanks
Filtering uitable results
Filtering uitable results
for a project I am working on I need to filter a UITableView(With two
labels for each cell) based on the date of a label but when I filter the
table using NSPredicate it just isn't working its updating the date labels
to only show the filter date but the task on the other label stays the
same.
After doing research all I can find to use is NSFetchedResultsController
but i havent a clue on how to go about implementing this. I have tried
researching it but its not working for me.
My arrays are:- taskObject dateObject filteredTaskObject filteredDateObject
Thanks in advanced for any help :)
for a project I am working on I need to filter a UITableView(With two
labels for each cell) based on the date of a label but when I filter the
table using NSPredicate it just isn't working its updating the date labels
to only show the filter date but the task on the other label stays the
same.
After doing research all I can find to use is NSFetchedResultsController
but i havent a clue on how to go about implementing this. I have tried
researching it but its not working for me.
My arrays are:- taskObject dateObject filteredTaskObject filteredDateObject
Thanks in advanced for any help :)
Regular expression replace does not seem to work
Regular expression replace does not seem to work
Dim i As String = StripTags(Request.QueryString("i").ToString())
Response.Write(Request.QueryString("i"))
Response.Write(i)
then my function looks like:
Function StripTags(ByVal html As String) As String
' Remove HTML tags.
Response.Write(html)
Return Regex.Replace(html, "<.*?%>", String.Empty)
End Function
the query string is: &i='%3bWAIT>FOR%20DELAY%20'0%3a0%3a25'--
the output i'm getting is:
';WAIT>FOR DELAY '0:0:25'--';WAIT>FOR DELAY '0:0:25'--';WAIT>FOR DELAY
'0:0:25'--
doesn't look like it's working. what am i missing?? i'm tried from staring
at it for an hour!
Dim i As String = StripTags(Request.QueryString("i").ToString())
Response.Write(Request.QueryString("i"))
Response.Write(i)
then my function looks like:
Function StripTags(ByVal html As String) As String
' Remove HTML tags.
Response.Write(html)
Return Regex.Replace(html, "<.*?%>", String.Empty)
End Function
the query string is: &i='%3bWAIT>FOR%20DELAY%20'0%3a0%3a25'--
the output i'm getting is:
';WAIT>FOR DELAY '0:0:25'--';WAIT>FOR DELAY '0:0:25'--';WAIT>FOR DELAY
'0:0:25'--
doesn't look like it's working. what am i missing?? i'm tried from staring
at it for an hour!
In Google Maps Api, change zoom with html tag event. BEGGINER
In Google Maps Api, change zoom with html tag event. BEGGINER
i'am a begginer in GMaps api and javascript, so this should be an easy
question for you that are really experts. I have started to "play around"
with the API, and wanted to try a simple thing, but I couldn't make it! I
have look around for the answer, but I didn't get it. I have created the
map:
<script type="text/javascript">
function initialize() {
//CREATE THE MAP
var mapOptions = {
center: new google.maps.LatLng(-35.8190,-61.9010),
zoom: 15,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
//GET THE ZOOM
var ez = map.getZoom();
//TRYING TO CHANGE ZOOM FROM EXTERNAL LINK (DOESN'T WORK)
function cambiarZOOM(nro) {
var newZ = ez + nro;
map.setZoom(newZ);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Now, the HTML:
<html><body onload="initialize()">
<input type="button" onclick="cambiarZOOM(5)" value="CAMBIAR ZOOM">
</body></html>
Well, now I'am reading about google.maps.trigger(); but I'm not getting
it. I will apreciate a lot your answer!. THANK YOU!
i'am a begginer in GMaps api and javascript, so this should be an easy
question for you that are really experts. I have started to "play around"
with the API, and wanted to try a simple thing, but I couldn't make it! I
have look around for the answer, but I didn't get it. I have created the
map:
<script type="text/javascript">
function initialize() {
//CREATE THE MAP
var mapOptions = {
center: new google.maps.LatLng(-35.8190,-61.9010),
zoom: 15,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
//GET THE ZOOM
var ez = map.getZoom();
//TRYING TO CHANGE ZOOM FROM EXTERNAL LINK (DOESN'T WORK)
function cambiarZOOM(nro) {
var newZ = ez + nro;
map.setZoom(newZ);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Now, the HTML:
<html><body onload="initialize()">
<input type="button" onclick="cambiarZOOM(5)" value="CAMBIAR ZOOM">
</body></html>
Well, now I'am reading about google.maps.trigger(); but I'm not getting
it. I will apreciate a lot your answer!. THANK YOU!
Align first line in TextView
Align first line in TextView
I have horizontally oriented LinearLayout with ImageView and TextView in
it (image at left, text at right). I want to align the first line of
TextView (even if it has multiple lines) to the center of ImageView. How
can I achieve that?
My current code, which centers the whole TextView instead of only the
first line:
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_distance" />
<TextView
android:duplicateParentState="true"
android:gravity="center_vertical"
style="@style/taskAddressText"
android:id="@+id/task_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
I have horizontally oriented LinearLayout with ImageView and TextView in
it (image at left, text at right). I want to align the first line of
TextView (even if it has multiple lines) to the center of ImageView. How
can I achieve that?
My current code, which centers the whole TextView instead of only the
first line:
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_distance" />
<TextView
android:duplicateParentState="true"
android:gravity="center_vertical"
style="@style/taskAddressText"
android:id="@+id/task_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
UDID Replacement in IOS7
UDID Replacement in IOS7
Is there is a alternative for UDID. My app will not be going to App Store
as i'm using enterprise distribution. So is there any replacement. I tied
advertising identifier, open udid, UIID and secure UDID. But if the phone
is reset then i will get a new UDID. Any help would be appreciated.
Is there is a alternative for UDID. My app will not be going to App Store
as i'm using enterprise distribution. So is there any replacement. I tied
advertising identifier, open udid, UIID and secure UDID. But if the phone
is reset then i will get a new UDID. Any help would be appreciated.
Tuesday, 17 September 2013
Create Video Playlist Manually (not from sd card)
Create Video Playlist Manually (not from sd card)
Anyone know how to create video playlist manually on android? and how to
play it? I want to play video from that playlist not from sd card/internal
phone.
and how to play video from listview? listview code:
int[] indexVideo =
{R.raw.saya,R.raw.anda,R.raw.aku,R.raw.dia,R.raw.kita,R.raw.lupa,R.raw.makan,R.raw.bahagia,
R.raw.bisa,
R.raw.belanja,R.raw.pergi,R.raw.pulang,R.raw.minum,R.raw.duduk};
How to play all of these video in listview?
Thank You
Anyone know how to create video playlist manually on android? and how to
play it? I want to play video from that playlist not from sd card/internal
phone.
and how to play video from listview? listview code:
int[] indexVideo =
{R.raw.saya,R.raw.anda,R.raw.aku,R.raw.dia,R.raw.kita,R.raw.lupa,R.raw.makan,R.raw.bahagia,
R.raw.bisa,
R.raw.belanja,R.raw.pergi,R.raw.pulang,R.raw.minum,R.raw.duduk};
How to play all of these video in listview?
Thank You
Mobile Application using .Net
Mobile Application using .Net
I know there are other questions posted with similar subject line. But I
believe, my requirement is very specific. I want to develop a mobile
application for Android phones using .Net(C#). I want know, which database
I can use and also best free APIs available for developing mobile
application(I have heard about Titanium Appcelerator). Kindly Help. Thanks
in advance.
I know there are other questions posted with similar subject line. But I
believe, my requirement is very specific. I want to develop a mobile
application for Android phones using .Net(C#). I want know, which database
I can use and also best free APIs available for developing mobile
application(I have heard about Titanium Appcelerator). Kindly Help. Thanks
in advance.
Android: Renaming images from camera
Android: Renaming images from camera
Currently I am using this code in my application to allow users to capture
photos.But how do i change the code so that after the users capture the
photo, it will be renamed to name such as "xxxx01.jpg"?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
_image = (ImageView) findViewById(R.id.image);
_field = (TextView) findViewById(R.id.field);
_button = (Button) findViewById(R.id.button);
_button.setOnClickListener(new ButtonClickHandler());
_path = Environment.getExternalStorageDirectory()
+ "/images/make_machine_example.jpg";
}
public class ButtonClickHandler implements View.OnClickListener {
@Override
public void onClick(View view) {
Log.i("MakeMachine", "ButtonClickHandler.onClick()");
startCameraActivity();
}
}
protected void startCameraActivity() {
Log.i("MakeMachine", "startCameraActivity()");
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
Log.i("MakeMachine", "resultCode: " + resultCode);
switch (resultCode) {
case 0:
Log.i("MakeMachine", "User cancelled");
break;
case -1:
onPhotoTaken();
break;
}
}
protected void onPhotoTaken() {
Log.i("MakeMachine", "onPhotoTaken");
_taken = true;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(_path, options);
_image.setImageBitmap(bitmap);
_field.setVisibility(View.GONE);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
Log.i("MakeMachine", "onRestoreInstanceState()");
if (savedInstanceState.getBoolean(PhotoCaptureExample.PHOTO_TAKEN)) {
onPhotoTaken();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean(PhotoCaptureExample.PHOTO_TAKEN, _taken);
}
}
Currently I am using this code in my application to allow users to capture
photos.But how do i change the code so that after the users capture the
photo, it will be renamed to name such as "xxxx01.jpg"?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
_image = (ImageView) findViewById(R.id.image);
_field = (TextView) findViewById(R.id.field);
_button = (Button) findViewById(R.id.button);
_button.setOnClickListener(new ButtonClickHandler());
_path = Environment.getExternalStorageDirectory()
+ "/images/make_machine_example.jpg";
}
public class ButtonClickHandler implements View.OnClickListener {
@Override
public void onClick(View view) {
Log.i("MakeMachine", "ButtonClickHandler.onClick()");
startCameraActivity();
}
}
protected void startCameraActivity() {
Log.i("MakeMachine", "startCameraActivity()");
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
Log.i("MakeMachine", "resultCode: " + resultCode);
switch (resultCode) {
case 0:
Log.i("MakeMachine", "User cancelled");
break;
case -1:
onPhotoTaken();
break;
}
}
protected void onPhotoTaken() {
Log.i("MakeMachine", "onPhotoTaken");
_taken = true;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(_path, options);
_image.setImageBitmap(bitmap);
_field.setVisibility(View.GONE);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
Log.i("MakeMachine", "onRestoreInstanceState()");
if (savedInstanceState.getBoolean(PhotoCaptureExample.PHOTO_TAKEN)) {
onPhotoTaken();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean(PhotoCaptureExample.PHOTO_TAKEN, _taken);
}
}
Scraping Javascript in PHP with Preg_Match
Scraping Javascript in PHP with Preg_Match
I am scraping a site with cURL and returning the output, then putting it
through the preg_match() function to retrieve certain things. When I try
to scrape the following it doesn't show anything.
preg_match('/var b=new (.*)var p=new /i', $bountyHTML, $ting);
$chou = $ting[1];
echo $chou;
The section in $bountyHTML I am trying to scrape from looks like this:
<script>
function fsb(x) {
var b=new
Array(101,55,100,99,52,49,57,50,54,56,51,55,54,49,51,50,101,50,49,50,100,54,49,97,50,53,52,99,100,57,54,53,51,100,49,54,55,38,101,101,49,104,61,101,61,50,50,49,56,99,110,111,78,50,109,114,111,102,38,52,61,100,101,55,105,95,98,116,115,105,51,108,48,116,105,97,104,63,112,104,52,112,97,49,46,121,55,56,52,101,102,54,50,116,110,117,52,111,98,47,101,54,57,52,57,101,53,99,98,102,56,48,98,51);
var p=new
Array(1,0,1,0,0,1,0,1,1,1,1,1,1,0,1,0,1,0,1,0,0,1,0,1,1,1,1,0,0,1,0,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,0,1,1,0,1,1,1,0,1,0,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var bountyForm = document.getElementById('bountyForm');
bountyForm.action = c(b,p) + x;
return true;
}
</script>
Any ideas why it wouldn't be returning anything? Thanks!
I am scraping a site with cURL and returning the output, then putting it
through the preg_match() function to retrieve certain things. When I try
to scrape the following it doesn't show anything.
preg_match('/var b=new (.*)var p=new /i', $bountyHTML, $ting);
$chou = $ting[1];
echo $chou;
The section in $bountyHTML I am trying to scrape from looks like this:
<script>
function fsb(x) {
var b=new
Array(101,55,100,99,52,49,57,50,54,56,51,55,54,49,51,50,101,50,49,50,100,54,49,97,50,53,52,99,100,57,54,53,51,100,49,54,55,38,101,101,49,104,61,101,61,50,50,49,56,99,110,111,78,50,109,114,111,102,38,52,61,100,101,55,105,95,98,116,115,105,51,108,48,116,105,97,104,63,112,104,52,112,97,49,46,121,55,56,52,101,102,54,50,116,110,117,52,111,98,47,101,54,57,52,57,101,53,99,98,102,56,48,98,51);
var p=new
Array(1,0,1,0,0,1,0,1,1,1,1,1,1,0,1,0,1,0,1,0,0,1,0,1,1,1,1,0,0,1,0,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,0,1,1,0,1,1,1,0,1,0,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var bountyForm = document.getElementById('bountyForm');
bountyForm.action = c(b,p) + x;
return true;
}
</script>
Any ideas why it wouldn't be returning anything? Thanks!
Dropdown boxes for WPF settings?
Dropdown boxes for WPF settings?
I am completely new to WPF and I tried to google this, so I'll ask here. I
am making a program that uses a DataGrid and I'm using Visual Studio 2010.
I selected this attribute
DataGrid->Columns->Collection->DataGridTextColumn->Layout->Width.
Under Width, the default is Auto. I am used to having a dropdown box for
the options. I see that I have choices marked by this link describing the
DataGridLength structure. Is there anyway I can have the dropdown boxes
instead? Or some other alternative that is fast and quick besides googling
the answer?
I am completely new to WPF and I tried to google this, so I'll ask here. I
am making a program that uses a DataGrid and I'm using Visual Studio 2010.
I selected this attribute
DataGrid->Columns->Collection->DataGridTextColumn->Layout->Width.
Under Width, the default is Auto. I am used to having a dropdown box for
the options. I see that I have choices marked by this link describing the
DataGridLength structure. Is there anyway I can have the dropdown boxes
instead? Or some other alternative that is fast and quick besides googling
the answer?
JSF interface error when get infomation
JSF interface error when get infomation
I'm a beginner in jsf. i created an interface to get infomation from user.
When i submit infomation it has an error like this:
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been
displayed.
sourceId=j_idt7:j_idt11[severity=(ERROR 2), summary=(j_idt7:j_idt11:
Validation Error: Value is not valid), detail=(j_idt7:j_idt11: Validation
Error: Value is not valid)]
I tried to sovle it but i can't understand . How can i solve it, thank for
helping.
I'm a beginner in jsf. i created an interface to get infomation from user.
When i submit infomation it has an error like this:
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been
displayed.
sourceId=j_idt7:j_idt11[severity=(ERROR 2), summary=(j_idt7:j_idt11:
Validation Error: Value is not valid), detail=(j_idt7:j_idt11: Validation
Error: Value is not valid)]
I tried to sovle it but i can't understand . How can i solve it, thank for
helping.
Sed help: string match
Sed help: string match
I have a few systems I where I need to modify the /etc/fstab. The fstab
contains
/var /var ext3 default,nodev,nosuid 1 2
/var/log /var/log ext3 default,nodev,nosuid 1 2
/var/log/audit /var/log/audit ext3 default,nodev,nosuid 1 2
I need to modify the /var entry removing the nodev mount option. I'd like
to use sed but cant' figure out how to modify that exact line. Everything
I've tried modifies all lines containing /var.
Would appreciate any help as I keep banging my head against the wall.
Thanks, Bert
I have a few systems I where I need to modify the /etc/fstab. The fstab
contains
/var /var ext3 default,nodev,nosuid 1 2
/var/log /var/log ext3 default,nodev,nosuid 1 2
/var/log/audit /var/log/audit ext3 default,nodev,nosuid 1 2
I need to modify the /var entry removing the nodev mount option. I'd like
to use sed but cant' figure out how to modify that exact line. Everything
I've tried modifies all lines containing /var.
Would appreciate any help as I keep banging my head against the wall.
Thanks, Bert
Sunday, 15 September 2013
How to pull rss feed of all Stack Overflow jobs in particular city?
How to pull rss feed of all Stack Overflow jobs in particular city?
I wish to pull an rss feed of all the Stack Overflow jobs for a particular
city. I know the link to get all of them
"http://careers.stackoverflow.com/jobs/feed" But how do i get all from
only Sydney for example?
I wish to pull an rss feed of all the Stack Overflow jobs for a particular
city. I know the link to get all of them
"http://careers.stackoverflow.com/jobs/feed" But how do i get all from
only Sydney for example?
Android: Eclipse won't run program onto my device
Android: Eclipse won't run program onto my device
I plugged in a Nexus 7, downloaded a project I was working on form Google
Drive. Now it won't run anywhere, only my other projects which I don't
care about. How to get it to run?
I plugged in a Nexus 7, downloaded a project I was working on form Google
Drive. Now it won't run anywhere, only my other projects which I don't
care about. How to get it to run?
Can I hide the text box value if the value is 0?
Can I hide the text box value if the value is 0?
Please help I am able to do all the calculations I need as long as I make
certain text boxes default value 0 but I do not want these boxes to show a
0 if nothing is put in them. Can I hide the text box if the value is 0?
there are servral text boxs in the sheet
Please help I am able to do all the calculations I need as long as I make
certain text boxes default value 0 but I do not want these boxes to show a
0 if nothing is put in them. Can I hide the text box if the value is 0?
there are servral text boxs in the sheet
Have a loading bar while a set of files is preloaded
Have a loading bar while a set of files is preloaded
I want to create a page with a video background (heavy video), and some
images and js files.
As it is all very heavy, I'd like to have a loading bar while all these
files are cached, and then start displaying everything else, including the
video.
I admit this is a bit vague, but please don't flag this question! I have
been searching for answers on my own, but I'm obviously not getting the
search query right. If you could just provide me with a link or the right
vocabulary to actually get good search results, I'd appreciate it.
I want to create a page with a video background (heavy video), and some
images and js files.
As it is all very heavy, I'd like to have a loading bar while all these
files are cached, and then start displaying everything else, including the
video.
I admit this is a bit vague, but please don't flag this question! I have
been searching for answers on my own, but I'm obviously not getting the
search query right. If you could just provide me with a link or the right
vocabulary to actually get good search results, I'd appreciate it.
All properties are set to last loop iteration value [why?]
All properties are set to last loop iteration value [why?]
Sample code:
var functions = {
testFunction: function(){
console.log('test');
}
};
var functionsClones = [];
for(i in [1,2,3]){
var functionsClone = $.extend({}, functions);
functionsClone.testFunction.i = i;
functionsClones.push(functionsClone);
}
$.extend is jQuery function which allows to clone object instead of
reffering to it.
Now let's print set properties:
$.each(functionsClones, function(key, functionsClone){
console.log(functionsClone.testFunction.i);
});
It outputs 3 times '2' instead of 0, 1, 2. What's wrong with this code?
Sample code:
var functions = {
testFunction: function(){
console.log('test');
}
};
var functionsClones = [];
for(i in [1,2,3]){
var functionsClone = $.extend({}, functions);
functionsClone.testFunction.i = i;
functionsClones.push(functionsClone);
}
$.extend is jQuery function which allows to clone object instead of
reffering to it.
Now let's print set properties:
$.each(functionsClones, function(key, functionsClone){
console.log(functionsClone.testFunction.i);
});
It outputs 3 times '2' instead of 0, 1, 2. What's wrong with this code?
Optimal database model for multilanguage websites
Optimal database model for multilanguage websites
My old database designs was looking like
id | name_en | title_en | name_ru | title_ru ...
I was searching for optimal database structure for multilingual websites
where I can add remove languages, posts ... etc without changing database
structure quite a long time.
Finally created one. But I'm not sure if it's optimal and it has several
fatal problems:
Language table - it's list of languages for whole application
-- ----------------------------
-- Table structure for Language
-- ----------------------------
DROP TABLE IF EXISTS `Language`;
CREATE TABLE `Language` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`iso` varchar(3) NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`order` tinyint(3) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
MenuType table - menu types like sidebar menu, top menu ...
-- ----------------------------
-- Table structure for MenuType
-- ----------------------------
DROP TABLE IF EXISTS `MenuType`;
CREATE TABLE `MenuType` (
`id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
Menu table - All menu items, based on parent child structure.
-- ----------------------------
-- Table structure for Menu
-- ----------------------------
DROP TABLE IF EXISTS `Menu`;
CREATE TABLE `Menu` (
`uid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`languageID` tinyint(3) unsigned DEFAULT NULL,
`menuTypeID` tinyint(2) unsigned DEFAULT NULL,
`order` int(2) DEFAULT NULL,
`parent` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
Page table - multilingual pages table
-- ----------------------------
-- Table structure for Page
-- ----------------------------
DROP TABLE IF EXISTS `Page`;
CREATE TABLE `Page` (
`uid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`languageID` tinyint(3) unsigned DEFAULT NULL,
`content` text COLLATE utf8_unicode_ci,
`deleted` tinyint(1) DEFAULT NULL,
`permalink` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Well my design works like that: lets say our project works on 2 language.
English (id 1 in language table) and Russian (id 2 in language table).
Ever page has 2 records in table: like {uid - 1, id - 2 lang - 1 ...};
{uid - 2 , id - 2, lang - 2 ...}.
I think it will have serious problems because of repeating id's with
foreign keys and programmatically will be difficult to maintain it. Any
suggestions to fix it or any other design suggestions?
Please share your multilingual database design ideas. I'm not experienced
in databases and really need some rock solid database design for using
long time in projects.
Thank you in advance.
My old database designs was looking like
id | name_en | title_en | name_ru | title_ru ...
I was searching for optimal database structure for multilingual websites
where I can add remove languages, posts ... etc without changing database
structure quite a long time.
Finally created one. But I'm not sure if it's optimal and it has several
fatal problems:
Language table - it's list of languages for whole application
-- ----------------------------
-- Table structure for Language
-- ----------------------------
DROP TABLE IF EXISTS `Language`;
CREATE TABLE `Language` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`iso` varchar(3) NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`order` tinyint(3) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
MenuType table - menu types like sidebar menu, top menu ...
-- ----------------------------
-- Table structure for MenuType
-- ----------------------------
DROP TABLE IF EXISTS `MenuType`;
CREATE TABLE `MenuType` (
`id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
Menu table - All menu items, based on parent child structure.
-- ----------------------------
-- Table structure for Menu
-- ----------------------------
DROP TABLE IF EXISTS `Menu`;
CREATE TABLE `Menu` (
`uid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`languageID` tinyint(3) unsigned DEFAULT NULL,
`menuTypeID` tinyint(2) unsigned DEFAULT NULL,
`order` int(2) DEFAULT NULL,
`parent` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
Page table - multilingual pages table
-- ----------------------------
-- Table structure for Page
-- ----------------------------
DROP TABLE IF EXISTS `Page`;
CREATE TABLE `Page` (
`uid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`languageID` tinyint(3) unsigned DEFAULT NULL,
`content` text COLLATE utf8_unicode_ci,
`deleted` tinyint(1) DEFAULT NULL,
`permalink` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Well my design works like that: lets say our project works on 2 language.
English (id 1 in language table) and Russian (id 2 in language table).
Ever page has 2 records in table: like {uid - 1, id - 2 lang - 1 ...};
{uid - 2 , id - 2, lang - 2 ...}.
I think it will have serious problems because of repeating id's with
foreign keys and programmatically will be difficult to maintain it. Any
suggestions to fix it or any other design suggestions?
Please share your multilingual database design ideas. I'm not experienced
in databases and really need some rock solid database design for using
long time in projects.
Thank you in advance.
Is it is possible to increase size of pictureBox or Highlight in On mouseover event in C#?
Is it is possible to increase size of pictureBox or Highlight in On
mouseover event in C#?
I am new to C#. Please help me. I wants to highlight or increase size of a
PictureBox when mouse move over it.
mouseover event in C#?
I am new to C#. Please help me. I wants to highlight or increase size of a
PictureBox when mouse move over it.
Saturday, 14 September 2013
Any drawbacks to use too much javascript in a Django powered site?
Any drawbacks to use too much javascript in a Django powered site?
I am new to Django framework. Now I am working on a website that powered
by Django on the backend, but since my unfamiliarity to Django, I did not
use a lot of "Django-style" front-end implementation.
Instead, I wrote a lot of Javascript code to retrieve Django page object
(which is passed in when calling render_to_response function or so), and I
almost did not use any Django-python script on the front-end. I wrote a
complete html code and load to browser at once, rather than use Django to
partially render the page components. I used regular HTML form than a
Django rendered form, and use a lot of ajax call to server, rather than a
Django-style submit.
I think what I am doing on the front-end is not taking any of the Django
advantages. I am not sure if this is OK too? Is there any advantages to
follow the Django style implementation? Is there any drawback on my
current work?
Thank you
I am new to Django framework. Now I am working on a website that powered
by Django on the backend, but since my unfamiliarity to Django, I did not
use a lot of "Django-style" front-end implementation.
Instead, I wrote a lot of Javascript code to retrieve Django page object
(which is passed in when calling render_to_response function or so), and I
almost did not use any Django-python script on the front-end. I wrote a
complete html code and load to browser at once, rather than use Django to
partially render the page components. I used regular HTML form than a
Django rendered form, and use a lot of ajax call to server, rather than a
Django-style submit.
I think what I am doing on the front-end is not taking any of the Django
advantages. I am not sure if this is OK too? Is there any advantages to
follow the Django style implementation? Is there any drawback on my
current work?
Thank you
cant access JSON response in callback AngularJS
cant access JSON response in callback AngularJS
In my net tab I am seeing the responses coming back but I can't get access
to the data for some reason.
Here is the direct link:
https://github.com/users/gigablox/contributions_calendar_data
Tried a couple different ways...
$http
var url =
"https://github.com/users/gigablox/contributions_calendar_data?callback=JSON_CALLBACK";
var data = [];
$http.jsonp(url).success(function(data){
console.log(data);
});
$resource
var handle =
$resource('https://github.com/users/gigablox/contributions_calendar_data',{},{
get:{
method:'JSONP',
isArray: false, //tried true and false
params:{callback:'JSON_CALLBACK'}
}
});
handle.get().$promise.then(
function(contributions){
console.log(contributions);
});
In my net tab I am seeing the responses coming back but I can't get access
to the data for some reason.
Here is the direct link:
https://github.com/users/gigablox/contributions_calendar_data
Tried a couple different ways...
$http
var url =
"https://github.com/users/gigablox/contributions_calendar_data?callback=JSON_CALLBACK";
var data = [];
$http.jsonp(url).success(function(data){
console.log(data);
});
$resource
var handle =
$resource('https://github.com/users/gigablox/contributions_calendar_data',{},{
get:{
method:'JSONP',
isArray: false, //tried true and false
params:{callback:'JSON_CALLBACK'}
}
});
handle.get().$promise.then(
function(contributions){
console.log(contributions);
});
Display the sum of the even numbers between two integers. Visual Basic.net
Display the sum of the even numbers between two integers. Visual Basic.net
I have a Visual Basic program that excepts two integers from the user. I
need to be able to display the sum of the even numbers between the two
integers entered by the user. If the user's entry is even, it should be
included in the sum. I am having trouble figuring out the algorithm. Thank
you in advance for any help you can give me.
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
Private Sub txtFirstNum_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtFirstNum.KeyPress
' allows the text box to accept only numbers, and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtSecondNum_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtSecondNum.KeyPress
' allows numbers and Backspace only
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles
btnDisplay.Click
' display the sum of even numbers
' declarations
Dim intFirstNum As Integer
Dim intSecondNum As Integer
' convert string to number with TryParse method
Integer.TryParse(txtFirstNum.Text, intFirstNum)
Integer.TryParse(txtSecondNum.Text, intSecondNum)
' find the even numbers
If intFirstNum Mod 2 = 0 Then
ElseIf intFirstNum Mod 2 = 1 Then
End If
' add the even numbers
' display the result
End Sub
End Class
I have a Visual Basic program that excepts two integers from the user. I
need to be able to display the sum of the even numbers between the two
integers entered by the user. If the user's entry is even, it should be
included in the sum. I am having trouble figuring out the algorithm. Thank
you in advance for any help you can give me.
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
Private Sub txtFirstNum_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtFirstNum.KeyPress
' allows the text box to accept only numbers, and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtSecondNum_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtSecondNum.KeyPress
' allows numbers and Backspace only
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles
btnDisplay.Click
' display the sum of even numbers
' declarations
Dim intFirstNum As Integer
Dim intSecondNum As Integer
' convert string to number with TryParse method
Integer.TryParse(txtFirstNum.Text, intFirstNum)
Integer.TryParse(txtSecondNum.Text, intSecondNum)
' find the even numbers
If intFirstNum Mod 2 = 0 Then
ElseIf intFirstNum Mod 2 = 1 Then
End If
' add the even numbers
' display the result
End Sub
End Class
Using (sqrt x) in Lisp code
Using (sqrt x) in Lisp code
I am having some issue while writing symbolic differentiation in lisp. I
am trying write derivative of sqrt (x) but when i use this variable inside
code, it give me that x is not defined.
;----------------------------------------
; deriv sqrt
;----------------------------------------
(defun derivsqrt(expr var)
(smult
(smult
(sdiv 1 2)
(sqrt (second expr)) ; This line gives me error
)
(deriv (second expr) var)
)
)
Can somebody help?
I am having some issue while writing symbolic differentiation in lisp. I
am trying write derivative of sqrt (x) but when i use this variable inside
code, it give me that x is not defined.
;----------------------------------------
; deriv sqrt
;----------------------------------------
(defun derivsqrt(expr var)
(smult
(smult
(sdiv 1 2)
(sqrt (second expr)) ; This line gives me error
)
(deriv (second expr) var)
)
)
Can somebody help?
Why do I have to specify model.name instead of just name?
Why do I have to specify model.name instead of just name?
Why do I have to specify model.name in the template below? I was under the
impression that a controller decorates its model. I thought I should be
able to do just {{ name }} in the template below. But it only works if I
do {{ model.name }}.
Any help greatly appreciated. Thanks!
app.js
App = Ember.Application.create({});
App.Router.map(function () {
this.resource("posts", { path: "/" }, function () {
this.route("new", { path: "/new" });
this.route("post", { path: ":post_id" });
});
this.route("another", { path: "/another" });
});
App.PostsRoute = Ember.Route.extend({
model: function(params) {
return [{ name: "foo" },{ name: "bar" },{ name: "zoo" }]
}
});
App.PostsPostRoute = Ember.Route.extend({
model: function(params) {
console.log('model');
return Ember.Object.create({ name: "MODEL name" })
}
});
App.PostsPostController = Ember.Controller.extend({
selected: false
});
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Test</title>
</head>
<body>
<script type="text/x-handlebars" id="posts">
posts here
{{#each controller}}
{{name}}
{{/each}}
{{ outlet }}
</script>
<script type="text/x-handlebars" id="posts/index">
posts index here
</script>
<script type="text/x-handlebars" id="posts/new">
posts new here
</script>
<script type="text/x-handlebars" id="posts/post">
here is a post???
{{ model.name }}
{{ selected }}
</script>
<script src="jquery-1.10.2.js"></script>
<script src="handlebars.js"></script>
<script src="ember.js"></script>
<script src="app.js"></script>
</body>
</html>
Why do I have to specify model.name in the template below? I was under the
impression that a controller decorates its model. I thought I should be
able to do just {{ name }} in the template below. But it only works if I
do {{ model.name }}.
Any help greatly appreciated. Thanks!
app.js
App = Ember.Application.create({});
App.Router.map(function () {
this.resource("posts", { path: "/" }, function () {
this.route("new", { path: "/new" });
this.route("post", { path: ":post_id" });
});
this.route("another", { path: "/another" });
});
App.PostsRoute = Ember.Route.extend({
model: function(params) {
return [{ name: "foo" },{ name: "bar" },{ name: "zoo" }]
}
});
App.PostsPostRoute = Ember.Route.extend({
model: function(params) {
console.log('model');
return Ember.Object.create({ name: "MODEL name" })
}
});
App.PostsPostController = Ember.Controller.extend({
selected: false
});
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Test</title>
</head>
<body>
<script type="text/x-handlebars" id="posts">
posts here
{{#each controller}}
{{name}}
{{/each}}
{{ outlet }}
</script>
<script type="text/x-handlebars" id="posts/index">
posts index here
</script>
<script type="text/x-handlebars" id="posts/new">
posts new here
</script>
<script type="text/x-handlebars" id="posts/post">
here is a post???
{{ model.name }}
{{ selected }}
</script>
<script src="jquery-1.10.2.js"></script>
<script src="handlebars.js"></script>
<script src="ember.js"></script>
<script src="app.js"></script>
</body>
</html>
Conditional Validation in ZF2
Conditional Validation in ZF2
I have a form which starts with a Select with two options. There are
several other fields, some of which are required for the first Select
option, and the others required for the second Select option.
In the view, I'm using the Select to show/hide the relevant/irrelevant
fields. Most of these fields are required when their option in the Select
is selected.
What is the best way to only validate the fields that are relevant to
whatever is selected in the Select?
I have a form which starts with a Select with two options. There are
several other fields, some of which are required for the first Select
option, and the others required for the second Select option.
In the view, I'm using the Select to show/hide the relevant/irrelevant
fields. Most of these fields are required when their option in the Select
is selected.
What is the best way to only validate the fields that are relevant to
whatever is selected in the Select?
Print More than one random number
Print More than one random number
I am new to python and self taught. I would like to create a simple Dice
rolling program but the problem I'm having is How to display more than one
random integer I know I have to specify the dice roll as an integer but
I'm not sure how Ill put part of the code below. # D&D Dice Roller
import random
import time
print("What dice would you like to roll")
sides = input()
if sides == 20:
D20roll = random.randint(1,20)
print ("How many dice would you like to roll")
D20 = input()
if D20 == 1:
print(D20roll)
if D20 == 2:
print(D20roll + "," + D20roll)
if D20 == 3:
print(D20roll + "," + D20roll + "," +D20roll)
I am new to python and self taught. I would like to create a simple Dice
rolling program but the problem I'm having is How to display more than one
random integer I know I have to specify the dice roll as an integer but
I'm not sure how Ill put part of the code below. # D&D Dice Roller
import random
import time
print("What dice would you like to roll")
sides = input()
if sides == 20:
D20roll = random.randint(1,20)
print ("How many dice would you like to roll")
D20 = input()
if D20 == 1:
print(D20roll)
if D20 == 2:
print(D20roll + "," + D20roll)
if D20 == 3:
print(D20roll + "," + D20roll + "," +D20roll)
Friday, 13 September 2013
Handler not behaving like a thread
Handler not behaving like a thread
Well so here is my Runnable code
// TODO Auto-generated method stub
Log.i(MyTag.Tag, "Started connecting");
String RawData = connect(link);//This method connects to the internet
Log.i(MyTag.Tag, "Finished connecting");
MyParser parse = new MyParser();
Document doc = null;
try {
Log.i(MyTag.Tag, "Starting parsing..");
doc = parse.parseAndReturn(RawData);
Log.i(MyTag.Tag, "Finished parsing");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DAF.finishLoading(doc);
The problem is, with a normal Thread, the app will stay for a few seconds at
connect(link)
,while it downloads the webpage before moving on to the rest of the code.
But with a handler, it just skips everything and goes all the way to
DAF.finishLoading(doc)
Which is not what I want.
I need a handler to allow the app to perform this method on a fixed
interval, but how do I make my handler behave like how I want with a
normal thread?
I know one method is to not use normal Runnables to perform internet
connectivity, but rather to use AsyncTask. But that is quite a hassle to
re-write everything so I was wondering if there is anyway to solve this
problem.
Well so here is my Runnable code
// TODO Auto-generated method stub
Log.i(MyTag.Tag, "Started connecting");
String RawData = connect(link);//This method connects to the internet
Log.i(MyTag.Tag, "Finished connecting");
MyParser parse = new MyParser();
Document doc = null;
try {
Log.i(MyTag.Tag, "Starting parsing..");
doc = parse.parseAndReturn(RawData);
Log.i(MyTag.Tag, "Finished parsing");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DAF.finishLoading(doc);
The problem is, with a normal Thread, the app will stay for a few seconds at
connect(link)
,while it downloads the webpage before moving on to the rest of the code.
But with a handler, it just skips everything and goes all the way to
DAF.finishLoading(doc)
Which is not what I want.
I need a handler to allow the app to perform this method on a fixed
interval, but how do I make my handler behave like how I want with a
normal thread?
I know one method is to not use normal Runnables to perform internet
connectivity, but rather to use AsyncTask. But that is quite a hassle to
re-write everything so I was wondering if there is anyway to solve this
problem.
javasctript removeEvent removes image when I click cancel
javasctript removeEvent removes image when I click cancel
Disclaimer:I am not a javascript expert.
Each time I upload an image and then I click on upload again but then
click cancel the image i had previously uploaded gets deleted. Can someone
please take a look at my javascript code and let me know how I can stop my
script from removing the image i had previously uploaded when I click on
cancel?
HTML Form:
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file
margin_5_0" onchange="ajaxUpload(this.form);" /><!-- end image label
and input -->
<br />
<input name="4_images" type="checkbox" value="" /> <label>Create 4
images</label><br />
<label>Thumbnail / Big Image</label><br />
<!-- begin display uploaded image -->
<div id="upload_area" class="corners align_center">
please select image
</div><!-- begin display uploaded image -->
Javascript code:
function $m(theVar){
return document.getElementById(theVar)
}
function remove(theVar){
var theParent = theVar.parentNode;
theParent.removeChild(theVar);
}
function addEvent(obj, evType, fn){
if(obj.addEventListener)
obj.addEventListener(evType, fn, true)
if(obj.attachEvent)
obj.attachEvent("on"+evType, fn)
}
function removeEvent(obj, type, fn){
if(obj.detachEvent){
obj.detachEvent('on'+type, fn);
}else{
obj.removeEventListener(type, fn, false);
}
}
// browser detection
function isWebKit(){
return RegExp(" AppleWebKit/").test(navigator.userAgent);
}
// send data
function ajaxUpload(form){
var detectWebKit = isWebKit();
var get_url = 'upload.php';// php file
var div_id = 'upload_area';// div id where to show uploaded image
var show_loading = '<img src="img/loading.gif" />';// loading image
var html_error = '<img src="img/error.png" />';// error image
// create iframe
var sendForm = document.createElement("iframe");
sendForm.setAttribute("id","uploadform-temp");
sendForm.setAttribute("name","uploadform-temp");
sendForm.setAttribute("width","0");
sendForm.setAttribute("height","0");
sendForm.setAttribute("border","0");
sendForm.setAttribute("style","width: 0; height: 0; border: none;");
// add to document
form.parentNode.appendChild(sendForm);
window.frames['uploadform-temp'].name="uploadform-temp";
// add event
var doUpload = function(){
removeEvent($m('uploadform-temp'),"load", doUpload);
var cross = "javascript: ";
cross += "window.parent.$m('"+div_id+"').innerHTML =
document.body.innerHTML; void(0);";
$m(div_id).innerHTML = html_error;
$m('uploadform-temp').src = cross;
if(detectWebKit){
remove($m('uploadform-temp'));
}else{
setTimeout(function(){ remove($m('uploadform-temp'))}, 1);
}
}
addEvent($m('uploadform-temp'),"load", doUpload);
// form proprietes
form.setAttribute("target","uploadform-temp");
form.setAttribute("action",get_url);
form.setAttribute("method","post");
form.setAttribute("enctype","multipart/form-data");
form.setAttribute("encoding","multipart/form-data");
// loading
if(show_loading.length > 0){
$m(div_id).innerHTML = show_loading;
}
// submit
form.submit();
return true;
}
Disclaimer:I am not a javascript expert.
Each time I upload an image and then I click on upload again but then
click cancel the image i had previously uploaded gets deleted. Can someone
please take a look at my javascript code and let me know how I can stop my
script from removing the image i had previously uploaded when I click on
cancel?
HTML Form:
<input type="file" size="45" name="uploadfile" id="uploadfile" class="file
margin_5_0" onchange="ajaxUpload(this.form);" /><!-- end image label
and input -->
<br />
<input name="4_images" type="checkbox" value="" /> <label>Create 4
images</label><br />
<label>Thumbnail / Big Image</label><br />
<!-- begin display uploaded image -->
<div id="upload_area" class="corners align_center">
please select image
</div><!-- begin display uploaded image -->
Javascript code:
function $m(theVar){
return document.getElementById(theVar)
}
function remove(theVar){
var theParent = theVar.parentNode;
theParent.removeChild(theVar);
}
function addEvent(obj, evType, fn){
if(obj.addEventListener)
obj.addEventListener(evType, fn, true)
if(obj.attachEvent)
obj.attachEvent("on"+evType, fn)
}
function removeEvent(obj, type, fn){
if(obj.detachEvent){
obj.detachEvent('on'+type, fn);
}else{
obj.removeEventListener(type, fn, false);
}
}
// browser detection
function isWebKit(){
return RegExp(" AppleWebKit/").test(navigator.userAgent);
}
// send data
function ajaxUpload(form){
var detectWebKit = isWebKit();
var get_url = 'upload.php';// php file
var div_id = 'upload_area';// div id where to show uploaded image
var show_loading = '<img src="img/loading.gif" />';// loading image
var html_error = '<img src="img/error.png" />';// error image
// create iframe
var sendForm = document.createElement("iframe");
sendForm.setAttribute("id","uploadform-temp");
sendForm.setAttribute("name","uploadform-temp");
sendForm.setAttribute("width","0");
sendForm.setAttribute("height","0");
sendForm.setAttribute("border","0");
sendForm.setAttribute("style","width: 0; height: 0; border: none;");
// add to document
form.parentNode.appendChild(sendForm);
window.frames['uploadform-temp'].name="uploadform-temp";
// add event
var doUpload = function(){
removeEvent($m('uploadform-temp'),"load", doUpload);
var cross = "javascript: ";
cross += "window.parent.$m('"+div_id+"').innerHTML =
document.body.innerHTML; void(0);";
$m(div_id).innerHTML = html_error;
$m('uploadform-temp').src = cross;
if(detectWebKit){
remove($m('uploadform-temp'));
}else{
setTimeout(function(){ remove($m('uploadform-temp'))}, 1);
}
}
addEvent($m('uploadform-temp'),"load", doUpload);
// form proprietes
form.setAttribute("target","uploadform-temp");
form.setAttribute("action",get_url);
form.setAttribute("method","post");
form.setAttribute("enctype","multipart/form-data");
form.setAttribute("encoding","multipart/form-data");
// loading
if(show_loading.length > 0){
$m(div_id).innerHTML = show_loading;
}
// submit
form.submit();
return true;
}
Ruby on Rails 4, Dynamicly create table for each user
Ruby on Rails 4, Dynamicly create table for each user
I'm new to Rails and I'm creating an Application where users can log in,
and it dynamicly generates a Table where they can make entries. I've
managed to make the login but I don't realize how to create a table which
is assosiated to a user.
my users_controller.rb class:
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.order(:name)
end
# GET /users/1
# GET /users/1.json
def show
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1/edit
def edit
end
# POST /users
# POST /users.json
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to login_url, notice: "User #{@user.name}
was successfully created." }
format.json { render action: 'show', status: :created, location:
@user }
#HERE I WOULD LIKE TO CREATE A TABLE ASSOSSIATED TO THE USER
@rapport_table = User.rapport_table.create
else
format.html { render action: 'new' }
format.json { render json: @user.errors, status:
:unprocessable_entity }
end
end
end
# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to users_url, notice: "User #{@user.name}
was successfully updated." }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @user.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white
list through.
def user_params
params.require(:user).permit(:name, :password, :password_confirmation)
end
end
rapport_table.rb
class RapportTable < ActiveRecord::Base
belongs_to :user
end
12341324123_create_rapport_tables.rb
class CreateRapportTables < ActiveRecord::Migration
def self.up
create_table :rapport_tables do |t|
t.date :date
t.text :description
t.integer :time
t.timestamps
end
end
def self.down
drop_table :rapport_tables
end
end
show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @user.name %>
</p>
<%= link_to 'Edit', edit_user_path(@user) %> |
<%= link_to 'Back', users_path %>
Thanks in Advance!
I'm new to Rails and I'm creating an Application where users can log in,
and it dynamicly generates a Table where they can make entries. I've
managed to make the login but I don't realize how to create a table which
is assosiated to a user.
my users_controller.rb class:
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.order(:name)
end
# GET /users/1
# GET /users/1.json
def show
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1/edit
def edit
end
# POST /users
# POST /users.json
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to login_url, notice: "User #{@user.name}
was successfully created." }
format.json { render action: 'show', status: :created, location:
@user }
#HERE I WOULD LIKE TO CREATE A TABLE ASSOSSIATED TO THE USER
@rapport_table = User.rapport_table.create
else
format.html { render action: 'new' }
format.json { render json: @user.errors, status:
:unprocessable_entity }
end
end
end
# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to users_url, notice: "User #{@user.name}
was successfully updated." }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @user.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white
list through.
def user_params
params.require(:user).permit(:name, :password, :password_confirmation)
end
end
rapport_table.rb
class RapportTable < ActiveRecord::Base
belongs_to :user
end
12341324123_create_rapport_tables.rb
class CreateRapportTables < ActiveRecord::Migration
def self.up
create_table :rapport_tables do |t|
t.date :date
t.text :description
t.integer :time
t.timestamps
end
end
def self.down
drop_table :rapport_tables
end
end
show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @user.name %>
</p>
<%= link_to 'Edit', edit_user_path(@user) %> |
<%= link_to 'Back', users_path %>
Thanks in Advance!
Does parallel_test [cucumber] allows user to run iOS tests on multiple machines in parallel?
Does parallel_test [cucumber] allows user to run iOS tests on multiple
machines in parallel?
I have my Frank tests for iOS and they are using cucumber. Is it possible
for me to use parallel test to distribute the .feature file to multiple
machines using parallels and invoke the tests on multiple iOS simulators
on different machine. If yes, how do you suggest to do this.
machines in parallel?
I have my Frank tests for iOS and they are using cucumber. Is it possible
for me to use parallel test to distribute the .feature file to multiple
machines using parallels and invoke the tests on multiple iOS simulators
on different machine. If yes, how do you suggest to do this.
Query regarding vhdl code
Query regarding vhdl code
I am just starting with learning vhdl. Consider the code here : -
http://esd.cs.ucr.edu/labs/tutorial/jkff.vhd
I can't understand what are concurrent statements and why are they needed
here? Will it be correct if we modify Q and Qbar directly in process p
without using internal signal 'state'?
I am just starting with learning vhdl. Consider the code here : -
http://esd.cs.ucr.edu/labs/tutorial/jkff.vhd
I can't understand what are concurrent statements and why are they needed
here? Will it be correct if we modify Q and Qbar directly in process p
without using internal signal 'state'?
IN Datagridview when first column combobox value changes then second column combobox selected values should clear
IN Datagridview when first column combobox value changes then second
column combobox selected values should clear
In datagridview i have two combobox columns and combobox2 get items based
on combobox1 selection.
It works good for the first row but when coming to the second row it works
fine same but first row combobox2 items changes to the combobox2 items in
second row.and when i want to change the combobox1 value combobox2 items
must clear first values and fill with latest values Please tell me what is
the solution for this
column combobox selected values should clear
In datagridview i have two combobox columns and combobox2 get items based
on combobox1 selection.
It works good for the first row but when coming to the second row it works
fine same but first row combobox2 items changes to the combobox2 items in
second row.and when i want to change the combobox1 value combobox2 items
must clear first values and fill with latest values Please tell me what is
the solution for this
Thursday, 12 September 2013
Javascript null or empty control does not work
Javascript null or empty control does not work
I open this subject for second time.
However there is no solution.
Below code does not work. I can enter empty(Space) value.
var veri = {
YeniMusteriEkleTextBox: $('#YeniMusteriAdiTextbox_I').val(),
};
if (!veri.YeniMusteriEkleTextBox) {
alert("Customer name can not be empty!");
}
I open this subject for second time.
However there is no solution.
Below code does not work. I can enter empty(Space) value.
var veri = {
YeniMusteriEkleTextBox: $('#YeniMusteriAdiTextbox_I').val(),
};
if (!veri.YeniMusteriEkleTextBox) {
alert("Customer name can not be empty!");
}
changing width of div to match width of span tag
changing width of div to match width of span tag
This is my first post here. I have been searching through questions
previously posted that sound similar to what I am encountering I've tried
those answers and still haven't made it work yet.
I got the following code. Somewhat similar to what I'm working on.
.ContentTable {
width:100%;
heigth:100%;
empty-cells:show;
}
.WidthLimited{
overflow:scroll;
overflow-x:auto;
overflow-y:hidden;
}
.ResultListContainer{
width:95%;
color:black;
}
<div id="Wrapper">
<div id="Content1"/>
<span id"SearchControl">
<table class="ContentTable">
<tbody>
<tr id="Title">Title here</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Footer">
<td>Some text</td>
</tr>
</tbody>
</table>
</span>
<div id="ResultList" class="WidthLimited">
<table class="ResultListContainer">
<tbody>
<tr id="Title">Title here</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Footer">
<td>Some text</td>
</tr>
</tbody>
</table>
</div>
</div>
Also got the following javascript to be able to adjust the width:
function fn_wrapperResultList()
{
var wObj = document.getElementById("wrapperResultList");
var pObj = document.getElementById("SearchControl");
if(window.attachEvent)
{
if(pObj.offsetWidth>wObj.offsetWidth)
{
wObj.style.width=pObj.offsetWidth;
}
}
else
{
wObj.style.width='100%';
}
}
In essence what I am trying to accomplish is to adjust the width of my
ResultList (which in this case is wider than my SearchControl) and match
the width of the SearchControl when the former's width is higher than the
latter's width (ResultList.width > SearchControl.width then adjust it).
If I assign a fixed width to my WidthLimited class, my control does change
and scroll-x is displayed with no problem and works as expected but I am
trying to make it change according to SearchControl.
I've tried lots of things: calculating the width using the
getComputedStyle and assigning it to wObj.style.width in that javascript
code which it does change when but still does not resizes. I added the
display:inline-block; to the .WidthLimited class and nothing. I read that
span does not really have a specific width but changing that piece is not
really an option at this point.
Is there a way to accomplish what I intend? I've been stuck for days now
and I am starting to pull my hair out. I really appreciate your help.
This is my first post here. I have been searching through questions
previously posted that sound similar to what I am encountering I've tried
those answers and still haven't made it work yet.
I got the following code. Somewhat similar to what I'm working on.
.ContentTable {
width:100%;
heigth:100%;
empty-cells:show;
}
.WidthLimited{
overflow:scroll;
overflow-x:auto;
overflow-y:hidden;
}
.ResultListContainer{
width:95%;
color:black;
}
<div id="Wrapper">
<div id="Content1"/>
<span id"SearchControl">
<table class="ContentTable">
<tbody>
<tr id="Title">Title here</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Footer">
<td>Some text</td>
</tr>
</tbody>
</table>
</span>
<div id="ResultList" class="WidthLimited">
<table class="ResultListContainer">
<tbody>
<tr id="Title">Title here</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Body">
<td>Some text 1</td>
<td>Some text 2</td>
<td>Some text 3</td>
</tr>
<tr id="Footer">
<td>Some text</td>
</tr>
</tbody>
</table>
</div>
</div>
Also got the following javascript to be able to adjust the width:
function fn_wrapperResultList()
{
var wObj = document.getElementById("wrapperResultList");
var pObj = document.getElementById("SearchControl");
if(window.attachEvent)
{
if(pObj.offsetWidth>wObj.offsetWidth)
{
wObj.style.width=pObj.offsetWidth;
}
}
else
{
wObj.style.width='100%';
}
}
In essence what I am trying to accomplish is to adjust the width of my
ResultList (which in this case is wider than my SearchControl) and match
the width of the SearchControl when the former's width is higher than the
latter's width (ResultList.width > SearchControl.width then adjust it).
If I assign a fixed width to my WidthLimited class, my control does change
and scroll-x is displayed with no problem and works as expected but I am
trying to make it change according to SearchControl.
I've tried lots of things: calculating the width using the
getComputedStyle and assigning it to wObj.style.width in that javascript
code which it does change when but still does not resizes. I added the
display:inline-block; to the .WidthLimited class and nothing. I read that
span does not really have a specific width but changing that piece is not
really an option at this point.
Is there a way to accomplish what I intend? I've been stuck for days now
and I am starting to pull my hair out. I really appreciate your help.
Loading bar not repainting java
Loading bar not repainting java
I have a loading bar that is not repainting every time I set it's value.
Iv'e tried maximizing and minimizing the screen many times but it still
shows 0% progress. The code is not finished yet. Any idea? Code:
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class LoadingTest {
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException,
UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
F f = new F("Loading Bar Test");
}
}
class F extends JFrame implements Runnable, ActionListener {
private static final long serialVersionUID = 4684842549708528589L;
private JProgressBar variableBar = new JProgressBar(0,100);
private JProgressBar randomGenBar = new JProgressBar(0,100);
private JProgressBar addBar = new JProgressBar(0,100);
private JProgressBar totalbar = new JProgressBar(0,100);
private JButton button;
public F(String str) {
setTitle(str);
setDefaultCloseOperation(3);
getContentPane().setLayout(new GridLayout(9,1));
variableBar.setStringPainted(true);
variableBar.setValue(0);
button = new JButton("Run Tasks");
button.addActionListener(this);
add(button);
add(new JLabel("Creating variables..."));
add(variableBar);
add(new JLabel("Generating Random Values..."));
add(randomGenBar);
add(new JLabel("Adding Values..."));
add(addBar);
add(new JLabel("Total Progress:"));
add(totalbar);
pack();
setVisible(true);
}
public void run() {
int p = 5;
int i1;
variableBar.setValue(p);
int i2;
p += 5;
variableBar.setValue(p);
int i3;
p += 5;
variableBar.setValue(p);
int i4;
p += 5;
variableBar.setValue(p);
int i5;
p += 5;
variableBar.setValue(p);
int i6;
p += 5;
variableBar.setValue(p);
int i7;
p += 5;
variableBar.setValue(p);
int i8;
p += 5;
variableBar.setValue(p);
int i9;
p += 5;
variableBar.setValue(p);
int i10;
p += 5;
variableBar.setValue(p);
int i11;
p += 5;
variableBar.setValue(p);
int i12;
p += 5;
variableBar.setValue(p);
int i13;
p += 5;
variableBar.setValue(p);
int i14;
p += 5;
variableBar.setValue(p);
int i15;
p += 5;
variableBar.setValue(p);
int i16;
p += 5;
variableBar.setValue(p);
int i17;
p += 5;
variableBar.setValue(p);
int i18;
p += 5;
variableBar.setValue(p);
int i19;
p += 5;
variableBar.setValue(p);
int i20;
p += 5;
variableBar.setValue(p);
}
private F() {
}
public void actionPerformed(ActionEvent e) {
new Thread(new F()).start();
}
}
I have a loading bar that is not repainting every time I set it's value.
Iv'e tried maximizing and minimizing the screen many times but it still
shows 0% progress. The code is not finished yet. Any idea? Code:
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class LoadingTest {
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException,
UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
F f = new F("Loading Bar Test");
}
}
class F extends JFrame implements Runnable, ActionListener {
private static final long serialVersionUID = 4684842549708528589L;
private JProgressBar variableBar = new JProgressBar(0,100);
private JProgressBar randomGenBar = new JProgressBar(0,100);
private JProgressBar addBar = new JProgressBar(0,100);
private JProgressBar totalbar = new JProgressBar(0,100);
private JButton button;
public F(String str) {
setTitle(str);
setDefaultCloseOperation(3);
getContentPane().setLayout(new GridLayout(9,1));
variableBar.setStringPainted(true);
variableBar.setValue(0);
button = new JButton("Run Tasks");
button.addActionListener(this);
add(button);
add(new JLabel("Creating variables..."));
add(variableBar);
add(new JLabel("Generating Random Values..."));
add(randomGenBar);
add(new JLabel("Adding Values..."));
add(addBar);
add(new JLabel("Total Progress:"));
add(totalbar);
pack();
setVisible(true);
}
public void run() {
int p = 5;
int i1;
variableBar.setValue(p);
int i2;
p += 5;
variableBar.setValue(p);
int i3;
p += 5;
variableBar.setValue(p);
int i4;
p += 5;
variableBar.setValue(p);
int i5;
p += 5;
variableBar.setValue(p);
int i6;
p += 5;
variableBar.setValue(p);
int i7;
p += 5;
variableBar.setValue(p);
int i8;
p += 5;
variableBar.setValue(p);
int i9;
p += 5;
variableBar.setValue(p);
int i10;
p += 5;
variableBar.setValue(p);
int i11;
p += 5;
variableBar.setValue(p);
int i12;
p += 5;
variableBar.setValue(p);
int i13;
p += 5;
variableBar.setValue(p);
int i14;
p += 5;
variableBar.setValue(p);
int i15;
p += 5;
variableBar.setValue(p);
int i16;
p += 5;
variableBar.setValue(p);
int i17;
p += 5;
variableBar.setValue(p);
int i18;
p += 5;
variableBar.setValue(p);
int i19;
p += 5;
variableBar.setValue(p);
int i20;
p += 5;
variableBar.setValue(p);
}
private F() {
}
public void actionPerformed(ActionEvent e) {
new Thread(new F()).start();
}
}
For mobile devices how can I temporarily prevent jQuery touch events while I am waiting for a JSON response?
For mobile devices how can I temporarily prevent jQuery touch events while
I am waiting for a JSON response?
For mobile devices how can I temporarily prevent jQuery touch events on a
page while I am waiting for a JSON response?
The JSON response will be used to create and update content on the page
but there are other elements with event handlers that I'd like to disable
(or stop users from activating them) until the JSON response has come back
and I have done the necessary adjustments to the page content.
With my limited experience I am considering two methods.
(1) I am considering creating or activating an overlaying div that
prevents jQuery event listeners on elements under the overlay from
detecting touch events. Something like a mobile version of
pointer-events:none; however I cannot find the mobile equivalent of
pointer-events:none;
(2) The other method I am considering is an Object that keep track off all
listeners and on command turns them .off() then once the JSON and
adjustments have finished I can re-attach them .on('click') however this
seems excessive if I can achieve what I want with the first method.
I am waiting for a JSON response?
For mobile devices how can I temporarily prevent jQuery touch events on a
page while I am waiting for a JSON response?
The JSON response will be used to create and update content on the page
but there are other elements with event handlers that I'd like to disable
(or stop users from activating them) until the JSON response has come back
and I have done the necessary adjustments to the page content.
With my limited experience I am considering two methods.
(1) I am considering creating or activating an overlaying div that
prevents jQuery event listeners on elements under the overlay from
detecting touch events. Something like a mobile version of
pointer-events:none; however I cannot find the mobile equivalent of
pointer-events:none;
(2) The other method I am considering is an Object that keep track off all
listeners and on command turns them .off() then once the JSON and
adjustments have finished I can re-attach them .on('click') however this
seems excessive if I can achieve what I want with the first method.
My daemon code is executing perfectly in the terminal but the log file is not getting created
My daemon code is executing perfectly in the terminal but the log file is
not getting created
The pid of the process is getting displayed in the terminal but log file
is not getting created in the root directory. Please go through this code
and tell me whats missing.
Output on terminal:
process_id of child process 5611
Source is below.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/inotify.h>
int main(int argc, char* argv[])
{
FILE *fp= NULL;
pid_t process_id = 0;
pid_t sid = 0;
int fd,wd,i=0,len=0;
char pathname[100],buf[1024];
process_id = fork();
if (process_id < 0)
{
printf("fork failed!\n");
exit(1);
}
if (process_id > 0)
{
printf("process_id of child process %d \n", process_id);
// return success in exit status
exit(0);
}
umask(0);
sid = setsid();
if(sid < 0)
{
exit(0);
}
chdir("/");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
fp = fopen ("log.txt", "w+");
fprintf(fp, "Logging info...\n");
fflush(fp);
fclose(fp);
sleep(1);
struct inotify_event *event;
fd=inotify_init();
wd=inotify_add_watch(fd,"/osa",IN_ALL_EVENTS);
while(1)
{
i=0;
len=read(fd,buf,1024);
fp = fopen ("log.txt", "w+");
fflush(fp);
while(i<len)
{
event=(struct inotify_event *) & buf[i];
if(event->mask & IN_OPEN)
{
fprintf(fp,"%s:was opened\n",event->name);
}
if(event->mask & IN_MODIFY)
{
fprintf(fp,"%s:file is modified",event->name);
}
if(event->mask & IN_DELETE)
{
fprintf(fp,"%s:was deleted\n",event->name);
}
i+=sizeof(struct inotify_event)+event->len;
}
fclose(fp);
}
return (0);
}
not getting created
The pid of the process is getting displayed in the terminal but log file
is not getting created in the root directory. Please go through this code
and tell me whats missing.
Output on terminal:
process_id of child process 5611
Source is below.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/inotify.h>
int main(int argc, char* argv[])
{
FILE *fp= NULL;
pid_t process_id = 0;
pid_t sid = 0;
int fd,wd,i=0,len=0;
char pathname[100],buf[1024];
process_id = fork();
if (process_id < 0)
{
printf("fork failed!\n");
exit(1);
}
if (process_id > 0)
{
printf("process_id of child process %d \n", process_id);
// return success in exit status
exit(0);
}
umask(0);
sid = setsid();
if(sid < 0)
{
exit(0);
}
chdir("/");
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
fp = fopen ("log.txt", "w+");
fprintf(fp, "Logging info...\n");
fflush(fp);
fclose(fp);
sleep(1);
struct inotify_event *event;
fd=inotify_init();
wd=inotify_add_watch(fd,"/osa",IN_ALL_EVENTS);
while(1)
{
i=0;
len=read(fd,buf,1024);
fp = fopen ("log.txt", "w+");
fflush(fp);
while(i<len)
{
event=(struct inotify_event *) & buf[i];
if(event->mask & IN_OPEN)
{
fprintf(fp,"%s:was opened\n",event->name);
}
if(event->mask & IN_MODIFY)
{
fprintf(fp,"%s:file is modified",event->name);
}
if(event->mask & IN_DELETE)
{
fprintf(fp,"%s:was deleted\n",event->name);
}
i+=sizeof(struct inotify_event)+event->len;
}
fclose(fp);
}
return (0);
}
Global Functions Objective C
Global Functions Objective C
I am trying to write a global function however keep getting the error "No
visible interface...." when i try and call it.
Popover.h
#import <Foundation/Foundation.h>
@interface Popover : NSObject{}
- (void)PopoverPlay;
@end
Popover.m
#import "Popover.h"
@implementation Popover
- (void)PopoverPlay{
NSLog(@"I Work");
}
@end
In View.m i am adding the import "Popover.h" but i cant get rid of the
error message when i try and run.
Any ideas Thanks
I am trying to write a global function however keep getting the error "No
visible interface...." when i try and call it.
Popover.h
#import <Foundation/Foundation.h>
@interface Popover : NSObject{}
- (void)PopoverPlay;
@end
Popover.m
#import "Popover.h"
@implementation Popover
- (void)PopoverPlay{
NSLog(@"I Work");
}
@end
In View.m i am adding the import "Popover.h" but i cant get rid of the
error message when i try and run.
Any ideas Thanks
Sencha Touch delete records in store based on condition
Sencha Touch delete records in store based on condition
I have a store with following code. I have 7 records in my store in which
first 3 record are having a status 2 and others have the status 3. I want
to delete the records whose status is 2.How do i go about
Ext.define('MyApp.store.MyStore', { extend: 'Ext.data.Store',
config: {
data: [
[
1,
'Siesta by the Ocean',
'1 Ocean Front, Happy Island',
1
],
[
2,
'Gulfwind',
'25 Ocean Front, Happy Island',
1
],
[
3,
'South Pole View',
'1 Southernmost Point, Antarctica',
1
],
[
4,
'ABC',
'11 Address1',
2
],
[
5,
'DEF',
'12 Address2',
2
],
[
6,
'GHI',
'13 Address3',
2
],
[
7,
'JKL',
'14 Address4',
2
]
],
storeId: 'MyStore',
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'name',
type: 'string'
},
{
name: 'address',
type: 'string'
},
{
name: 'status',
type: 'int'
}
],
proxy: {
type: 'localstorage'
}
}
});
I have a store with following code. I have 7 records in my store in which
first 3 record are having a status 2 and others have the status 3. I want
to delete the records whose status is 2.How do i go about
Ext.define('MyApp.store.MyStore', { extend: 'Ext.data.Store',
config: {
data: [
[
1,
'Siesta by the Ocean',
'1 Ocean Front, Happy Island',
1
],
[
2,
'Gulfwind',
'25 Ocean Front, Happy Island',
1
],
[
3,
'South Pole View',
'1 Southernmost Point, Antarctica',
1
],
[
4,
'ABC',
'11 Address1',
2
],
[
5,
'DEF',
'12 Address2',
2
],
[
6,
'GHI',
'13 Address3',
2
],
[
7,
'JKL',
'14 Address4',
2
]
],
storeId: 'MyStore',
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'name',
type: 'string'
},
{
name: 'address',
type: 'string'
},
{
name: 'status',
type: 'int'
}
],
proxy: {
type: 'localstorage'
}
}
});
Is there a proper formatter for boost::uint64_t to use with snprintf?
Is there a proper formatter for boost::uint64_t to use with snprintf?
I am using boost/cstdint.hpp in a C++ project because I am compiling in
C++03 mode (-std=c++03) and I want to have fixed-width integers (they are
transmitted over the network and stored to files). I am also using
snprintf because it is a simple and fast way to format strings.
Is there a proper formatter to use boost::uint64_t with snprintf(...) or
should I switch to another solution (boost::format, std::ostringstream) ?
I am current using %lu but I am not fully happy with it as it may not work
on another architecture (where boost::uint64_t is not defined as long
unsigned), defeating the purpose of using fixed-width integers.
boost::uint64_t id
id = get_file_id(...)
const char* ENCODED_FILENAME_FORMAT = "encoded%lu.dat";
//...
char encoded_filename[34];
snprintf(encoded_filename, 34, ENCODED_FILENAME_FORMAT, id);
I am using boost/cstdint.hpp in a C++ project because I am compiling in
C++03 mode (-std=c++03) and I want to have fixed-width integers (they are
transmitted over the network and stored to files). I am also using
snprintf because it is a simple and fast way to format strings.
Is there a proper formatter to use boost::uint64_t with snprintf(...) or
should I switch to another solution (boost::format, std::ostringstream) ?
I am current using %lu but I am not fully happy with it as it may not work
on another architecture (where boost::uint64_t is not defined as long
unsigned), defeating the purpose of using fixed-width integers.
boost::uint64_t id
id = get_file_id(...)
const char* ENCODED_FILENAME_FORMAT = "encoded%lu.dat";
//...
char encoded_filename[34];
snprintf(encoded_filename, 34, ENCODED_FILENAME_FORMAT, id);
Wednesday, 11 September 2013
add list in popupwindow
add list in popupwindow
I have to make an application where I have to show a list of names in popup.
I have used array-list to fetch the values from database, but I cannot put
it in array-adapter. here is my code:
public class Calculator_new_Pop extends Dialog implements
View.OnClickListener{
.............
.............
.............
ArrayList<String> wallAreas=new ArrayList<String>();
wallAreas=GenericDAO.getWallAreas(room_id);//to fetch the values from
databases
ArrayAdapter<String> new_adapter = new
ArrayAdapter<String>(Calculator_new_Pop.this,android.R.layout.simple_list_item_1,wallAreas);
_ltvw.setAdapter(new_adapter);
.......
}
the error is
"The constructor ArrayAdapter(Calculator_new_Pop, int, ArrayList) is
undefined"
Can anyone help me out?
I have to make an application where I have to show a list of names in popup.
I have used array-list to fetch the values from database, but I cannot put
it in array-adapter. here is my code:
public class Calculator_new_Pop extends Dialog implements
View.OnClickListener{
.............
.............
.............
ArrayList<String> wallAreas=new ArrayList<String>();
wallAreas=GenericDAO.getWallAreas(room_id);//to fetch the values from
databases
ArrayAdapter<String> new_adapter = new
ArrayAdapter<String>(Calculator_new_Pop.this,android.R.layout.simple_list_item_1,wallAreas);
_ltvw.setAdapter(new_adapter);
.......
}
the error is
"The constructor ArrayAdapter(Calculator_new_Pop, int, ArrayList) is
undefined"
Can anyone help me out?
Image on front page of report won't fit with page footer present
Image on front page of report won't fit with page footer present
I'm using Reporting Services with VS2010 The report must be exported to PDF.
The first page of the report has a full-sized A4 image (with multiple
colours right to the edges). Subsequent report pages have a footer with
page number etc.
I cannot get everything to fit properly. If I have a page footer, and
deselect show on front page, blank space is allowed for on the front page
so the image overruns.
I tried to use the image as the background on the report and on the body
but this just repeats the image on every page (even if I use clipped).
I also tried adding in the front page as a separately defined report.
I tried using a bottom strip of the image in the footer with a condition
for it being the first page - this worked almost but a thin empty strip
between the two pieces of the image (page one and the footer) shows when
exported to PDF
I tried removing the page footer and creating my own footer type text box
but then I can't use page numbers and there is also a variable number of
pages in the report.
Is there some way to achieve this? - To have a full A4 sized image on page
one and page footers on each subsequent pages.
I'm using Reporting Services with VS2010 The report must be exported to PDF.
The first page of the report has a full-sized A4 image (with multiple
colours right to the edges). Subsequent report pages have a footer with
page number etc.
I cannot get everything to fit properly. If I have a page footer, and
deselect show on front page, blank space is allowed for on the front page
so the image overruns.
I tried to use the image as the background on the report and on the body
but this just repeats the image on every page (even if I use clipped).
I also tried adding in the front page as a separately defined report.
I tried using a bottom strip of the image in the footer with a condition
for it being the first page - this worked almost but a thin empty strip
between the two pieces of the image (page one and the footer) shows when
exported to PDF
I tried removing the page footer and creating my own footer type text box
but then I can't use page numbers and there is also a variable number of
pages in the report.
Is there some way to achieve this? - To have a full A4 sized image on page
one and page footers on each subsequent pages.
Hibernate foreign key without reference to foreign key Entity
Hibernate foreign key without reference to foreign key Entity
I use Hibernate 4.2. I have two tables say Employee and Employer. I have
employer_id in employee table as foreign key.
Now in Employee.java file can I have
@Column(name="employer_id")
private Integer employerId;
I want to have a Employer reference in Employee as I don't want to fetch
Employer data every time I fetch employee.
I use Hibernate 4.2. I have two tables say Employee and Employer. I have
employer_id in employee table as foreign key.
Now in Employee.java file can I have
@Column(name="employer_id")
private Integer employerId;
I want to have a Employer reference in Employee as I don't want to fetch
Employer data every time I fetch employee.
Largest prime factor in RUBY
Largest prime factor in RUBY
Can someone please tell me what im doing wrong.
x=13195, n=2, max=n
for n in (2...x)
if (x%n==0)
prime=true
for y in (1...n)
if n%y==0
prime=false
end
y+=1
end
if prime
max=n
end
end
n+=1
end
puts "#{max}"
Can someone please tell me what im doing wrong.
x=13195, n=2, max=n
for n in (2...x)
if (x%n==0)
prime=true
for y in (1...n)
if n%y==0
prime=false
end
y+=1
end
if prime
max=n
end
end
n+=1
end
puts "#{max}"
Change the auto-complete behaviour of a textbox
Change the auto-complete behaviour of a textbox
I have two doubts about the autocomplete feature of textboxes in C#.
First, I want to display the full list, not only the ones that start with
the given text, and secondly I want to prevent the auto-complete of
specific options (some are category titles).
I've been checking the textbox properties and there's nothing related to
it, so probably the main question could be, Is there a way to modify /
override the textbox events in order to handle the auto-complete actions?
(I don't know if it applies to show the full list too)
I have two doubts about the autocomplete feature of textboxes in C#.
First, I want to display the full list, not only the ones that start with
the given text, and secondly I want to prevent the auto-complete of
specific options (some are category titles).
I've been checking the textbox properties and there's nothing related to
it, so probably the main question could be, Is there a way to modify /
override the textbox events in order to handle the auto-complete actions?
(I don't know if it applies to show the full list too)
using CreateNames for sheet-only names vba
using CreateNames for sheet-only names vba
I am using
ActiveCell.CurrentRegion.CreateNames top:=True, left:=False
this is effective in naming the columns at the top. I need to make these
named ranges local to the sheet. Is there a way to do this with the
CreateNames instead of the Names.Add?
Any help would be much appreciate.
I am using
ActiveCell.CurrentRegion.CreateNames top:=True, left:=False
this is effective in naming the columns at the top. I need to make these
named ranges local to the sheet. Is there a way to do this with the
CreateNames instead of the Names.Add?
Any help would be much appreciate.
Check if row used by another table
Check if row used by another table
I have a table emails_accounts with a structure like this:
¨X¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨[
¨U id ¨U email ¨U description ¨U
¨d¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨g
¨U 1 ¨U test@gmail.com ¨U Lorem ¨U
¨U 2 ¨U example@example.com ¨U Ipsum ¨U
¨U 3 ¨U test@example.com ¨U Dolor ¨U
¨U 4 ¨U retail@example.com ¨U Sit Amet ¨U
¨^¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨a
And a second table email_templates with a structure similiar to this:
¨X¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨[
¨U id ¨U email_title ¨U email_from ¨U email_to ¨U
¨d¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨g
¨U 1 ¨U Test title ¨U 1 ¨U 3 ¨U
¨U 2 ¨U Second title ¨U 2 ¨U 3 ¨U
¨U 3 ¨U Some title ¨U 1 ¨U 1 ¨U
¨^¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨a
What I want to achieve is to create a SQL query which gives me ALL
accounts from the table emails_accounts but with additional information -
how much every account is used in a table email_templates (it needs to
check email_from and email_to).
I know it shouldn't be too hard, but so far I didn't manage to get the
results right. My code at the moment is:
SELECT acc.* , COUNT( temp.id )
FROM emails_accounts acc
LEFT JOIN email_templates temp ON acc.id = temp.email_from
GROUP BY acc.email
But I would like to have both email_from and email_to counted.
I tried also this:
SELECT acc . * , COUNT( temp.id ) + COUNT( temp2.id ) AS count
FROM emails_accounts acc
LEFT JOIN email_templates temp ON acc.id = temp.email_from
LEFT JOIN email_templates temp2 ON acc.id = temp2.email_to
GROUP BY acc.email
But it gives too many results.
I have a table emails_accounts with a structure like this:
¨X¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨[
¨U id ¨U email ¨U description ¨U
¨d¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨g
¨U 1 ¨U test@gmail.com ¨U Lorem ¨U
¨U 2 ¨U example@example.com ¨U Ipsum ¨U
¨U 3 ¨U test@example.com ¨U Dolor ¨U
¨U 4 ¨U retail@example.com ¨U Sit Amet ¨U
¨^¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨a
And a second table email_templates with a structure similiar to this:
¨X¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨j¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨[
¨U id ¨U email_title ¨U email_from ¨U email_to ¨U
¨d¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨p¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨g
¨U 1 ¨U Test title ¨U 1 ¨U 3 ¨U
¨U 2 ¨U Second title ¨U 2 ¨U 3 ¨U
¨U 3 ¨U Some title ¨U 1 ¨U 1 ¨U
¨^¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨m¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨a
What I want to achieve is to create a SQL query which gives me ALL
accounts from the table emails_accounts but with additional information -
how much every account is used in a table email_templates (it needs to
check email_from and email_to).
I know it shouldn't be too hard, but so far I didn't manage to get the
results right. My code at the moment is:
SELECT acc.* , COUNT( temp.id )
FROM emails_accounts acc
LEFT JOIN email_templates temp ON acc.id = temp.email_from
GROUP BY acc.email
But I would like to have both email_from and email_to counted.
I tried also this:
SELECT acc . * , COUNT( temp.id ) + COUNT( temp2.id ) AS count
FROM emails_accounts acc
LEFT JOIN email_templates temp ON acc.id = temp.email_from
LEFT JOIN email_templates temp2 ON acc.id = temp2.email_to
GROUP BY acc.email
But it gives too many results.
Subscribe to:
Comments (Atom)