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.
Subscribe to:
Posts (Atom)