MediaWiki category-page relation
Do categories that a page belong to are saved in the MediaWiki schema? I
want fetch all pages that have a specific category.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Can you make Golang drop packets on writes rather than block?
Can you make Golang drop packets on writes rather than block?
Given a channel of length N, I want to write to it only if it is not full.
Else I will drop this packet and process the next one.
Is this possible in GOlang
Given a channel of length N, I want to write to it only if it is not full.
Else I will drop this packet and process the next one.
Is this possible in GOlang
Installing project's dependencies globally and running the project without `node=?iso-8859-1?Q?=5Fmodules/`_=97_how=3F?=
Installing project's dependencies globally and running the project without
`node_modules/` — how?
I decided to try learning DerbyJS and this is my first acquaintance with
NodeJS either.
I create a new Node/Derby project with derby new foo. This also creates a
node_modules/ folder which contains a copy of all packages the project
depends on.
The node_modules/ subdir of a blank Derby project is 144 MB large and
contains 12967 files (sic!). As a person familiar with Ruby's RubyGems,
RVM and Bundler, i find this insane. I can't express how wrong it is
(actually i've got some solid argumentation against that craziness but
StackOverflow is not a place for debate).
I thought that npm's -g flag would help me. I could install all packages
globally, i told myself. So i did:
derby new -n foo
cd foo
sudo npm install -g
Now my project weighs 152 KB and contains 24 files. Now that's reasonable.
But i fail to run it. When i do npm start, i get "Cannot find module
'express'":
lolmaus@sandy:~/hello_derby2$ npm start
> hello_derby2@0.0.0 start /home/lolmaus/hello_derby2
> node server.js
Master pid 29884
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous>
(/home/lolmaus/hello_derby2/lib/server/index.js:1:77)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
So the question is: how do install project's dependencies into a central
local repository and run the project without beating the f#@k out of my
Dropbox account?
`node_modules/` — how?
I decided to try learning DerbyJS and this is my first acquaintance with
NodeJS either.
I create a new Node/Derby project with derby new foo. This also creates a
node_modules/ folder which contains a copy of all packages the project
depends on.
The node_modules/ subdir of a blank Derby project is 144 MB large and
contains 12967 files (sic!). As a person familiar with Ruby's RubyGems,
RVM and Bundler, i find this insane. I can't express how wrong it is
(actually i've got some solid argumentation against that craziness but
StackOverflow is not a place for debate).
I thought that npm's -g flag would help me. I could install all packages
globally, i told myself. So i did:
derby new -n foo
cd foo
sudo npm install -g
Now my project weighs 152 KB and contains 24 files. Now that's reasonable.
But i fail to run it. When i do npm start, i get "Cannot find module
'express'":
lolmaus@sandy:~/hello_derby2$ npm start
> hello_derby2@0.0.0 start /home/lolmaus/hello_derby2
> node server.js
Master pid 29884
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous>
(/home/lolmaus/hello_derby2/lib/server/index.js:1:77)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
So the question is: how do install project's dependencies into a central
local repository and run the project without beating the f#@k out of my
Dropbox account?
linux redhat 6 and installing easy_install
linux redhat 6 and installing easy_install
I'm completely new at this and needed a bit of help.
I've got a hosted server running Linux Redhat 6 and using Python 2.7
(which has just been set as the default from Python 2.6) located at
/usr/local/bin/python2.7
I'm trying to setup easy_install on the server, but I'm not sure if i'm
doing it correctly, on the bash screen i'm running: sudo apt-get install
python-setuptools
But it keeps asking for a sudo password, which i'm assuming is my normal
admin password that i've used to login via SSH? I've used my admin
password and my root password which both don't seem to work, can any one
help? Maybe it's an over sight from my side (being a newbie). Thanks
Gareth
I'm completely new at this and needed a bit of help.
I've got a hosted server running Linux Redhat 6 and using Python 2.7
(which has just been set as the default from Python 2.6) located at
/usr/local/bin/python2.7
I'm trying to setup easy_install on the server, but I'm not sure if i'm
doing it correctly, on the bash screen i'm running: sudo apt-get install
python-setuptools
But it keeps asking for a sudo password, which i'm assuming is my normal
admin password that i've used to login via SSH? I've used my admin
password and my root password which both don't seem to work, can any one
help? Maybe it's an over sight from my side (being a newbie). Thanks
Gareth
Tuesday, 1 October 2013
bootstrap collapse add class for open item
bootstrap collapse add class for open item
I have used bootstrap framework for display collapsible panels in my
webpage. By default the first panel is open. I need to add class to the
opened panel's head on page load. If i click any panel the class should be
removed. How to do this?
I have used bootstrap framework for display collapsible panels in my
webpage. By default the first panel is open. I need to add class to the
opened panel's head on page load. If i click any panel the class should be
removed. How to do this?
DesignTime Data
DesignTime Data
I have an ItemsControl that is bound at runtime to data fetched from the
web. but I'd like to be able to preview its item template in the visual
designer. I'm able to do this in WPF, but not in windows phone.
I've tried to check for DesignerProperties.IsInDesignTool in the
constructor of the page and if true add the items manually to the items
control, but it doesn't work.
I considered having a static resource with a list of items and binding to
it, but there's no <x:Array> in windows phone also.
I also tried setting ItemsSource="{d:DesignInstance
IsDesignTimeCreatable=True, Type=src:MyType, CreateList=True}" but it also
didn't work
I have an ItemsControl that is bound at runtime to data fetched from the
web. but I'd like to be able to preview its item template in the visual
designer. I'm able to do this in WPF, but not in windows phone.
I've tried to check for DesignerProperties.IsInDesignTool in the
constructor of the page and if true add the items manually to the items
control, but it doesn't work.
I considered having a static resource with a list of items and binding to
it, but there's no <x:Array> in windows phone also.
I also tried setting ItemsSource="{d:DesignInstance
IsDesignTimeCreatable=True, Type=src:MyType, CreateList=True}" but it also
didn't work
Thinkpad W530, cannot save to windows partition
Thinkpad W530, cannot save to windows partition
I recently purchased a Thinkpad W530 laptop from Lenovo with Windows 7 on
it. I installed Lubuntu 13.04 on it, and then mounted my OS partition in
Lubuntu 13.04. I have found that whenever I tried to save a file into this
partition (any file, any directory), Lubuntu seems to transfer or save the
files just fine, and I am able to edit them without any apparent errors in
Lubuntu. However, when I shutdown and reboot into Windows, not only are
those files GONE (not even hidden, actually gone) but when I shutdown and
reboot back into Lubuntu the files are gone there as well. In addition,
when I run a chkdsk in Windows, it shows that the files I transferred are
actually corrupted and must be deleted. I should mention that I had also
tried this same test by removing Lubuntu and using Xubuntu, with the same
results.
I have installed Ubuntu, Lubuntu, SUSE, and other distros on my previous
personal computers without any such problems ever arising. So, I am very
confused by this behavior. Does anyone have any advice regarding this
problem, or has anyone solved this problem on their own machines?
I recently purchased a Thinkpad W530 laptop from Lenovo with Windows 7 on
it. I installed Lubuntu 13.04 on it, and then mounted my OS partition in
Lubuntu 13.04. I have found that whenever I tried to save a file into this
partition (any file, any directory), Lubuntu seems to transfer or save the
files just fine, and I am able to edit them without any apparent errors in
Lubuntu. However, when I shutdown and reboot into Windows, not only are
those files GONE (not even hidden, actually gone) but when I shutdown and
reboot back into Lubuntu the files are gone there as well. In addition,
when I run a chkdsk in Windows, it shows that the files I transferred are
actually corrupted and must be deleted. I should mention that I had also
tried this same test by removing Lubuntu and using Xubuntu, with the same
results.
I have installed Ubuntu, Lubuntu, SUSE, and other distros on my previous
personal computers without any such problems ever arising. So, I am very
confused by this behavior. Does anyone have any advice regarding this
problem, or has anyone solved this problem on their own machines?
Help me understand the tensor product
Help me understand the tensor product
I have several books and other literature that define the tensor product,
but I understand none of them. Since this really concerns one topic,
namely understanding the construction of and arithmetic of (with?) tensor
products, I'll pose a few questions here instead of asking them
separately. I don't feel that the specific case of tensoring vector spaces
helps with understanding the general construction, so my questions will
deal with tensoring a right $R$-module with a left $R$-module over the
ring $R$, which we do not assume to be commutative.
1) Now then, the first step is to form the free abelian group $F(M \times
N)$. I've never stumbled upon free abelian groups prior to reading about
the tensor product, but it seems simple enough. Correct me if I'm wrong,
but $F(M \times N) = \{ \sum a_{ij}(m,n) \mid a_{ij} \in \mathbb{Z} \}$,
the sums ranging over all $(m,n) \in M \times N$. But some authors say
something else, which I trust is the same thing but nevertheless confuses
me. Keith Conrad (assuming $R$ is commutative) says $$R=\bigoplus_{(m,n)
\in M \times N} R \delta_{(m,n)}$$ without any mention of what
$\delta_{(m,n)}$ is, but it's probably similar to what I have in a
compendium (which also assumes the ring is commutative), "notation tagging
the component that corresponds to the element $(m,n) \in M \times N$".
What does that even mean, and why is that particular notation only used
when $R$ is assumed commutative?
2) Next define the subgroup $S \subset F(M \times N)$ generated by "all
elements of the following three types" $(a,b+b') - (a,b) - (a,b')$ etc.
Well, what does $-$ mean? Is an equivalence relation meant? If so, when
are they considered equivalent? I've only seen this along the lines of
"define $x,y$ to be equivalent if property $P(x,y)$ holds".
3) $M \otimes N$ is an abelian group. Fine, so how are elements "added"?
No mention of this is made in any of my literature, except that $a \otimes
(b+b') = a \otimes b + a \otimes b'$, but how about $a \otimes b + c
\otimes d$?
4) So-called elementary or pure tensors. Conrad writes "Tensors in $M
\otimes_R N$ that have the form $m \otimes n$ are called elementary
tensors". The elementary tensors span the tensor product (right?), but
what elements of $F(M \times N)$ wind up as elementary tensors? While my
compendium (which, as Conrad, assumes the ring to be commutative) also
makes note of elementary tensors, Rotman ("Introduction to Homological
Algebra"), not assuming commutativity, makes no mention of them, but says:
"Since $A \otimes_R B$ is generated by the elements of the form $a \otimes
b$, every $u \in A \otimes_R B$ has the form $u = \sum_i a_i \otimes b_i$.
This expression is not unique..." The other names for "elementary tensor"
which Conrad lists are not in the index to Rotman's book, so are
elementary tensors only relevant to tensoring over a commutative ring?
Thanks in advance for any help. I've had some homework regarding tensors
and I'm unable to take even a first step in answering the questions, so I
have to learn tensor products somehow.
Conrad: http://www.math.uconn.edu/~kconrad/blurbs/linmultialg/tensorprod.pdf
I have several books and other literature that define the tensor product,
but I understand none of them. Since this really concerns one topic,
namely understanding the construction of and arithmetic of (with?) tensor
products, I'll pose a few questions here instead of asking them
separately. I don't feel that the specific case of tensoring vector spaces
helps with understanding the general construction, so my questions will
deal with tensoring a right $R$-module with a left $R$-module over the
ring $R$, which we do not assume to be commutative.
1) Now then, the first step is to form the free abelian group $F(M \times
N)$. I've never stumbled upon free abelian groups prior to reading about
the tensor product, but it seems simple enough. Correct me if I'm wrong,
but $F(M \times N) = \{ \sum a_{ij}(m,n) \mid a_{ij} \in \mathbb{Z} \}$,
the sums ranging over all $(m,n) \in M \times N$. But some authors say
something else, which I trust is the same thing but nevertheless confuses
me. Keith Conrad (assuming $R$ is commutative) says $$R=\bigoplus_{(m,n)
\in M \times N} R \delta_{(m,n)}$$ without any mention of what
$\delta_{(m,n)}$ is, but it's probably similar to what I have in a
compendium (which also assumes the ring is commutative), "notation tagging
the component that corresponds to the element $(m,n) \in M \times N$".
What does that even mean, and why is that particular notation only used
when $R$ is assumed commutative?
2) Next define the subgroup $S \subset F(M \times N)$ generated by "all
elements of the following three types" $(a,b+b') - (a,b) - (a,b')$ etc.
Well, what does $-$ mean? Is an equivalence relation meant? If so, when
are they considered equivalent? I've only seen this along the lines of
"define $x,y$ to be equivalent if property $P(x,y)$ holds".
3) $M \otimes N$ is an abelian group. Fine, so how are elements "added"?
No mention of this is made in any of my literature, except that $a \otimes
(b+b') = a \otimes b + a \otimes b'$, but how about $a \otimes b + c
\otimes d$?
4) So-called elementary or pure tensors. Conrad writes "Tensors in $M
\otimes_R N$ that have the form $m \otimes n$ are called elementary
tensors". The elementary tensors span the tensor product (right?), but
what elements of $F(M \times N)$ wind up as elementary tensors? While my
compendium (which, as Conrad, assumes the ring to be commutative) also
makes note of elementary tensors, Rotman ("Introduction to Homological
Algebra"), not assuming commutativity, makes no mention of them, but says:
"Since $A \otimes_R B$ is generated by the elements of the form $a \otimes
b$, every $u \in A \otimes_R B$ has the form $u = \sum_i a_i \otimes b_i$.
This expression is not unique..." The other names for "elementary tensor"
which Conrad lists are not in the index to Rotman's book, so are
elementary tensors only relevant to tensoring over a commutative ring?
Thanks in advance for any help. I've had some homework regarding tensors
and I'm unable to take even a first step in answering the questions, so I
have to learn tensor products somehow.
Conrad: http://www.math.uconn.edu/~kconrad/blurbs/linmultialg/tensorprod.pdf
Monday, 30 September 2013
Ubuntu with all audio drivers
Ubuntu with all audio drivers
Is there an ubuntu that comes pre-installed with all audio drivers
considering that I dont have access to the internet that much
Is there an ubuntu that comes pre-installed with all audio drivers
considering that I dont have access to the internet that much
IP Alias and port bridging
IP Alias and port bridging
The situation is that I have an Ubuntu box with multiple ethernet ports,
which I'd like to behave as if connected to the computer through a switch.
I can achieve this easily with a bridge. In /etc/network/interfaces:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
Under this config, another device can plug into any of the ports and ping
this box at 192.168.1.1.
Now, the second part is that I'd like one of the ports to have an IP
alias, whereby it also tries to get a DHCP address. I can do this on eth0
without the bridge, like so:
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
iface eth0:0 inet dhcp
Now the trick is, how would I combine this with the software switch
functionality? Because brctl operates at layer 2, I can't create eth0:0
once eth0 is part of br0. The only thing I can do is create it as br0:0:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
iface br0:0 inet dhcp
This actually does almost exactly what I'd like, but with one weird
problem: When the ethernet ports are disconnected or there's no DHCP
server, the bridge doesn't get its proper static IP---or it'll get it, but
not until a minute or two after the bootup is otherwise complete.
So my question is, what's up with the delay? Can I get rid of it somehow?
Alternatively, is there a better way I could accomplish what I want here?
The ideal thing would be a daemon which would periodically poll for DHCP,
and when it gets an IP assigns, puts it on the alias instead of the main
interface.
Thanks.
The situation is that I have an Ubuntu box with multiple ethernet ports,
which I'd like to behave as if connected to the computer through a switch.
I can achieve this easily with a bridge. In /etc/network/interfaces:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
Under this config, another device can plug into any of the ports and ping
this box at 192.168.1.1.
Now, the second part is that I'd like one of the ports to have an IP
alias, whereby it also tries to get a DHCP address. I can do this on eth0
without the bridge, like so:
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
iface eth0:0 inet dhcp
Now the trick is, how would I combine this with the software switch
functionality? Because brctl operates at layer 2, I can't create eth0:0
once eth0 is part of br0. The only thing I can do is create it as br0:0:
iface br0 inet static
bridge_ports regex eth.*
address 192.168.1.1
netmask 255.255.255.0
iface br0:0 inet dhcp
This actually does almost exactly what I'd like, but with one weird
problem: When the ethernet ports are disconnected or there's no DHCP
server, the bridge doesn't get its proper static IP---or it'll get it, but
not until a minute or two after the bootup is otherwise complete.
So my question is, what's up with the delay? Can I get rid of it somehow?
Alternatively, is there a better way I could accomplish what I want here?
The ideal thing would be a daemon which would periodically poll for DHCP,
and when it gets an IP assigns, puts it on the alias instead of the main
interface.
Thanks.
NameError: global name 'parentid_id' is not defined
NameError: global name 'parentid_id' is not defined
I am getting the following Error Message.I can't understand why it happens
and how to solve it.
Internal Server Error: /location/0/
Traceback (most recent call last):
File "D:\Python27\lib\site-packages\django\core\handlers\base.py", line
115, i
n get_response
response = callback(request, *callback_args, **callback_kwargs)
File "D:\Project\myproject\radio\views.py", line 33, in location_show
arrs = Regions.objects.filter(parentid_id in ListFirst)
Modles.py
class Regions(models.Model):
id =models.AutoField(primary_key=True)
name = models.CharField(max_length=30)
english_name = models.CharField(max_length=20)
parentid = models.ForeignKey('self', blank=True,null=True)
slug_name = models.SlugField(max_length=40,blank=True)
regions_level = models.PositiveIntegerField()
comment = models.CharField(max_length=50,blank=True,null=True)
class Radio(models.Model):
station_name = models.CharField(max_length=30)
description = models.TextField()
regions = models.ForeignKey(Regions,blank=True,null=True)
custom_url = models.SlugField(max_length=100,blank=True)
stream = models.ForeignKey(Stream,related_name='radio_stream')
attributes = models.OneToOneField(Attributes,blank=True,null=True)
type = models.ForeignKey(Type,related_name='radio_type')
tags = models.ManyToManyField(Tag, blank=True)
comment =
models.ForeignKey(Comment,related_name='radio_comment',blank=True,null=True)
publish_time = models.DateTimeField(auto_now_add=True)
update_time = models.DateTimeField(auto_now_add=True)
Views.py
def location_show(request, id):
try:
radio_single = Regions.objects.get(id = id)
if radio_single.regions_level == 0:
ars = Regions.objects.filter(parentid_id=id)
ListFirst = [f.id for f in ars]
arrs = Regions.objects.filter(parentid_id in ListFirst)
ListSencond = [s.id for s in arrs]
arrss = Regions.objects.filter(parentid in ListSecond)
ListThird = [t.id for t in arrss]
listFirst.extend(ListSecond)
ListFirst.extend(listThird)
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
elif radio_single.regions_level == 1:
ars = Regions.objects.filter(parentid_id=id)
listFirst = [p.id for p in ars]
arss = Regions.objects.filter(parentid in ListFirst)
ListsSecond = [s.id for s in arss]
ListFirst.extend(ListSecond)
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
elif radio_single.regions_level == 2:
ars = Regions.objects.filter(parentid_id=id)
ListFirst= [p.id for p in ars]
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
else:
ars = Regions.objects.filter(parentid_id = id)
ListFirst = [f.id for f in ars]
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
except Radio.DoesNotExist:
raise Http404
would really appreciate a little help if anyone knows where i am going
wrong and can explain.
I am getting the following Error Message.I can't understand why it happens
and how to solve it.
Internal Server Error: /location/0/
Traceback (most recent call last):
File "D:\Python27\lib\site-packages\django\core\handlers\base.py", line
115, i
n get_response
response = callback(request, *callback_args, **callback_kwargs)
File "D:\Project\myproject\radio\views.py", line 33, in location_show
arrs = Regions.objects.filter(parentid_id in ListFirst)
Modles.py
class Regions(models.Model):
id =models.AutoField(primary_key=True)
name = models.CharField(max_length=30)
english_name = models.CharField(max_length=20)
parentid = models.ForeignKey('self', blank=True,null=True)
slug_name = models.SlugField(max_length=40,blank=True)
regions_level = models.PositiveIntegerField()
comment = models.CharField(max_length=50,blank=True,null=True)
class Radio(models.Model):
station_name = models.CharField(max_length=30)
description = models.TextField()
regions = models.ForeignKey(Regions,blank=True,null=True)
custom_url = models.SlugField(max_length=100,blank=True)
stream = models.ForeignKey(Stream,related_name='radio_stream')
attributes = models.OneToOneField(Attributes,blank=True,null=True)
type = models.ForeignKey(Type,related_name='radio_type')
tags = models.ManyToManyField(Tag, blank=True)
comment =
models.ForeignKey(Comment,related_name='radio_comment',blank=True,null=True)
publish_time = models.DateTimeField(auto_now_add=True)
update_time = models.DateTimeField(auto_now_add=True)
Views.py
def location_show(request, id):
try:
radio_single = Regions.objects.get(id = id)
if radio_single.regions_level == 0:
ars = Regions.objects.filter(parentid_id=id)
ListFirst = [f.id for f in ars]
arrs = Regions.objects.filter(parentid_id in ListFirst)
ListSencond = [s.id for s in arrs]
arrss = Regions.objects.filter(parentid in ListSecond)
ListThird = [t.id for t in arrss]
listFirst.extend(ListSecond)
ListFirst.extend(listThird)
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
elif radio_single.regions_level == 1:
ars = Regions.objects.filter(parentid_id=id)
listFirst = [p.id for p in ars]
arss = Regions.objects.filter(parentid in ListFirst)
ListsSecond = [s.id for s in arss]
ListFirst.extend(ListSecond)
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
elif radio_single.regions_level == 2:
ars = Regions.objects.filter(parentid_id=id)
ListFirst= [p.id for p in ars]
ListFirst.append(id)
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
else:
ars = Regions.objects.filter(parentid_id = id)
ListFirst = [f.id for f in ars]
radios = Radio.objects.filter(regions in ListFirst)
return
render_to_response("radio_location_show.html",{"ars":ars,"radios":radios})
except Radio.DoesNotExist:
raise Http404
would really appreciate a little help if anyone knows where i am going
wrong and can explain.
how to scroll to the loaded ui-view
how to scroll to the loaded ui-view
I have a ui-view inside of my page. When some button is clicked, the
ui-view is loaded and replaced by some HTML. I want the page to be
scrolled down to the just-loaded part of the page. Is this possible?
Thanks in advance
I have a ui-view inside of my page. When some button is clicked, the
ui-view is loaded and replaced by some HTML. I want the page to be
scrolled down to the just-loaded part of the page. Is this possible?
Thanks in advance
Sunday, 29 September 2013
MySQL database unrecognize chinese characters extracted from Excel file (xls)
MySQL database unrecognize chinese characters extracted from Excel file (xls)
I try to extract data (Chinese Charaters) from excel(.xls), but when
inserted, the database does not recognize the characters (appear blank and
symbols). Please help me to solve the problems.
<html>
<body>
<form action="upload_file_xls.php" method="post"
enctype="multipart/form-data">
<input type="file" name="file" id="file" /><br/>
<input type="submit" name="insert" value="Upload"/>
</form>
</body>
<?php
if(isset($_POST['insert'])){
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] ;
}
else{
include 'excel/reader.php';
$excel = new Spreadsheet_Excel_Reader();
$file = $_FILES['file']['tmp_name'];
$excel->read($file);
$x=1;
while($x<=$excel->sheets[0]['numRows']) {
$number = isset($excel->sheets[0]['cells'][$x][1]) ?
$excel->sheets[0]['cells'][$x][1] : '';
$province = isset($excel->sheets[0]['cells'][$x][2]) ?
$excel->sheets[0]['cells'][$x][2] : '';
$city = isset($excel->sheets[0]['cells'][$x][3]) ?
$excel->sheets[0]['cells'][$x][3] : '';
$alphabet = isset($excel->sheets[0]['cells'][$x][4]) ?
$excel->sheets[0]['cells'][$x][4] : '';
$link = mysql_connect('localhost', 'root', '');
mysql_set_charset('utf8',$link);
$db_selected = mysql_select_db('sugoroku01', $link);
if (!$db_selected) { die ('Database access error : ' .
mysql_error());}
$query = "INSERT INTO `province_city_tbl`(`province`,
`city`, `alphabet`)
VALUES ('".$province."', '".$city."',
'".$alphabet."') ";
mysql_query($query) or die('Error, Feedback insert
into database failed');
$x++;
}
}
}
?>
</html>
I try to extract data (Chinese Charaters) from excel(.xls), but when
inserted, the database does not recognize the characters (appear blank and
symbols). Please help me to solve the problems.
<html>
<body>
<form action="upload_file_xls.php" method="post"
enctype="multipart/form-data">
<input type="file" name="file" id="file" /><br/>
<input type="submit" name="insert" value="Upload"/>
</form>
</body>
<?php
if(isset($_POST['insert'])){
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] ;
}
else{
include 'excel/reader.php';
$excel = new Spreadsheet_Excel_Reader();
$file = $_FILES['file']['tmp_name'];
$excel->read($file);
$x=1;
while($x<=$excel->sheets[0]['numRows']) {
$number = isset($excel->sheets[0]['cells'][$x][1]) ?
$excel->sheets[0]['cells'][$x][1] : '';
$province = isset($excel->sheets[0]['cells'][$x][2]) ?
$excel->sheets[0]['cells'][$x][2] : '';
$city = isset($excel->sheets[0]['cells'][$x][3]) ?
$excel->sheets[0]['cells'][$x][3] : '';
$alphabet = isset($excel->sheets[0]['cells'][$x][4]) ?
$excel->sheets[0]['cells'][$x][4] : '';
$link = mysql_connect('localhost', 'root', '');
mysql_set_charset('utf8',$link);
$db_selected = mysql_select_db('sugoroku01', $link);
if (!$db_selected) { die ('Database access error : ' .
mysql_error());}
$query = "INSERT INTO `province_city_tbl`(`province`,
`city`, `alphabet`)
VALUES ('".$province."', '".$city."',
'".$alphabet."') ";
mysql_query($query) or die('Error, Feedback insert
into database failed');
$x++;
}
}
}
?>
</html>
Celery log shows cleanup failed
Celery log shows cleanup failed
I am using celery with django. I see an error when I lookup the celery log
for the automatically scheduled cleanup. I am not sure what this means,
and the implications of not doing the cleanup. Any help is appreciated.
[2013-09-28 23:00:00,204: ERROR/MainProcess] Task
celery.backend_cleanup[65af1634-374a-4068-b1a5-749b70f7c78d] raised
exception: NotImplementedError('No updates',)
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py",
line 228, in trace_task
R = retval = fun(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py",
line 415, in __protected_call__
return self.run(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/app/builtins.py",
line 58, in backend_cleanup
app.backend.cleanup()
File
"/usr/local/lib/python2.7/dist-packages/djcelery/backends/database.py",
line 58, in cleanup
model._default_manager.delete_expired(expires)
File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line
110, in delete_expired
self.get_all_expired(expires).update(hidden=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 469, in update
rows = query.get_compiler(self.db).execute_sql(None)
File
"/usr/local/lib/python2.7/dist-packages/djangotoolbox/db/basecompiler.py",
line 376, in execute_sql
raise NotImplementedError('No updates')
I am using celery with django. I see an error when I lookup the celery log
for the automatically scheduled cleanup. I am not sure what this means,
and the implications of not doing the cleanup. Any help is appreciated.
[2013-09-28 23:00:00,204: ERROR/MainProcess] Task
celery.backend_cleanup[65af1634-374a-4068-b1a5-749b70f7c78d] raised
exception: NotImplementedError('No updates',)
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py",
line 228, in trace_task
R = retval = fun(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/task/trace.py",
line 415, in __protected_call__
return self.run(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/celery-3.0.15-py2.7.egg/celery/app/builtins.py",
line 58, in backend_cleanup
app.backend.cleanup()
File
"/usr/local/lib/python2.7/dist-packages/djcelery/backends/database.py",
line 58, in cleanup
model._default_manager.delete_expired(expires)
File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line
110, in delete_expired
self.get_all_expired(expires).update(hidden=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 469, in update
rows = query.get_compiler(self.db).execute_sql(None)
File
"/usr/local/lib/python2.7/dist-packages/djangotoolbox/db/basecompiler.py",
line 376, in execute_sql
raise NotImplementedError('No updates')
HTML body is not at the top of the page even with margin set to 0
HTML body is not at the top of the page even with margin set to 0
This is a Ruby on Rails app and I can't get the body at the top of the
page. Screenshot:
I have no clue why this is happening as I've set all the properties
correctly. Here is the source of the entire application. My view:
<div id="header-wrap">
<div id="header">
<h1>Blog</h1>
</div>
</div>
<div id="wrapper">
<div id="posts">
<% @posts.each do|post| %>
<div id="post">
<h2><%= post.title %></h2>
<%= simple_format post.body %>
<small>
<%= link_to 'Edit', edit_post_path(post) %> |
<%= link_to 'Destroy', post, method: :delete, data: { confirm:
'Are you sure?' } %>
</small>
</div>
<% end %>
</div>
<br>
<%= link_to 'New Post', new_post_path %>
</div>
My CSS (the commented out CSS is the hack I wrote to fix the issue by
changing the positioning of the header-wrap and wrapper elements):
/*
* This is a manifest file that'll be compiled into application.css, which
will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets,
vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here
using a relative path.
*
* You're free to add application-wide styles to this file and they'll
appear at the top of the
* compiled file, but it's generally better to create a new file per style
scope.
*
*= require_self
*= require_tree .
*= require twitter/bootstrap
*/
html, body, {
background-image:url('bg.png');
background-color:#cccccc;
padding: 0;
margin: 0;
}
#header-wrap {
background-color: #424242;
/* position: absolute;*/
height: 100px;
width: 100%;
top: 0;
}
#header {
margin: 0 auto;
color: #FFFFFF;
width: 588px;
}
#wrapper {
/* position: relative;
top: 100px;*/
padding: 0 6px;
margin: 0 auto;
width: 588px;
}
#posts {
}
#notice {
color: green;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}
This is a Ruby on Rails app and I can't get the body at the top of the
page. Screenshot:
I have no clue why this is happening as I've set all the properties
correctly. Here is the source of the entire application. My view:
<div id="header-wrap">
<div id="header">
<h1>Blog</h1>
</div>
</div>
<div id="wrapper">
<div id="posts">
<% @posts.each do|post| %>
<div id="post">
<h2><%= post.title %></h2>
<%= simple_format post.body %>
<small>
<%= link_to 'Edit', edit_post_path(post) %> |
<%= link_to 'Destroy', post, method: :delete, data: { confirm:
'Are you sure?' } %>
</small>
</div>
<% end %>
</div>
<br>
<%= link_to 'New Post', new_post_path %>
</div>
My CSS (the commented out CSS is the hack I wrote to fix the issue by
changing the positioning of the header-wrap and wrapper elements):
/*
* This is a manifest file that'll be compiled into application.css, which
will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets,
vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here
using a relative path.
*
* You're free to add application-wide styles to this file and they'll
appear at the top of the
* compiled file, but it's generally better to create a new file per style
scope.
*
*= require_self
*= require_tree .
*= require twitter/bootstrap
*/
html, body, {
background-image:url('bg.png');
background-color:#cccccc;
padding: 0;
margin: 0;
}
#header-wrap {
background-color: #424242;
/* position: absolute;*/
height: 100px;
width: 100%;
top: 0;
}
#header {
margin: 0 auto;
color: #FFFFFF;
width: 588px;
}
#wrapper {
/* position: relative;
top: 100px;*/
padding: 0 6px;
margin: 0 auto;
width: 588px;
}
#posts {
}
#notice {
color: green;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}
Saturday, 28 September 2013
freemarker.core.InvalidReferenceException: Error on line 261, column 13 in --->
freemarker.core.InvalidReferenceException: Error on line 261, column 13 in
--->
It throws the error that like below when I upgrade the struts 2 to version
2.3.15.1 from version 2.2.1.1 FreeMarker template error!
Error on line 261, column 13 in template/simple/optiontransferselect.ftl
stack.findValue(parameters.doubleListKey) is undefined. It cannot be
assigned to doubleItemKey
The problematic instruction:
==> assignment: doubleItemKey=stack.findValue(parameters.doubleListKey)
[on line 261, column 13 in template/simple/optiontransferselect.ftl]
in user-directive s.iterator [on line 259, column 9 in
template/simple/optiontransferselect.ftl]
Java backtrace for programmers:
freemarker.core.InvalidReferenceException: Error on line 261, column 13 in
template/simple/optiontransferselect.ftl
stack.findValue(parameters.doubleListKey) is undefined. It cannot be
assigned to doubleItemKey at
freemarker.core.Assignment.accept(Assignment.java:111) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.IfBlock.accept(IfBlock.java:82) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.MixedContent.accept(MixedContent.java:92) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.Environment.visit(Environment.java:310) at
freemarker.core.UnifiedCall.accept(UnifiedCall.java:130) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.MixedContent.accept(MixedContent.java:92) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.Environment.process(Environment.java:199) at
freemarker.template.Template.process(Template.java:259) at
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:157)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:572) at
org.apache.struts2.components.UIBean.end(UIBean.java:526) at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspx_meth_s_005foptiontransferselect_005f0(UserDefinedInfo_jsp.java:737)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspx_meth_s_005fform_005f1(UserDefinedInfo_jsp.java:651)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspService(UserDefinedInfo_jsp.java:387)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
at
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at
com.gimis.gframe.system.interceptor.QueryInterceptor.doIntercept(QueryInterceptor.java:75)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.gframe.system.interceptor.OperationLogInterceptor.doIntercept(OperationLogInterceptor.java:62)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.core.interceptor.TranceActionInterceptor.doIntercept(TranceActionInterceptor.java:45)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.core.interceptor.ExceptionInterceptor.doIntercept(ExceptionInterceptor.java:44)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.gframe.system.interceptor.SecurityInterceptor.doIntercept(SecurityInterceptor.java:89)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:93)
at org.apache.cata
--->
It throws the error that like below when I upgrade the struts 2 to version
2.3.15.1 from version 2.2.1.1 FreeMarker template error!
Error on line 261, column 13 in template/simple/optiontransferselect.ftl
stack.findValue(parameters.doubleListKey) is undefined. It cannot be
assigned to doubleItemKey
The problematic instruction:
==> assignment: doubleItemKey=stack.findValue(parameters.doubleListKey)
[on line 261, column 13 in template/simple/optiontransferselect.ftl]
in user-directive s.iterator [on line 259, column 9 in
template/simple/optiontransferselect.ftl]
Java backtrace for programmers:
freemarker.core.InvalidReferenceException: Error on line 261, column 13 in
template/simple/optiontransferselect.ftl
stack.findValue(parameters.doubleListKey) is undefined. It cannot be
assigned to doubleItemKey at
freemarker.core.Assignment.accept(Assignment.java:111) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.IfBlock.accept(IfBlock.java:82) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.MixedContent.accept(MixedContent.java:92) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.Environment.visit(Environment.java:310) at
freemarker.core.UnifiedCall.accept(UnifiedCall.java:130) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.MixedContent.accept(MixedContent.java:92) at
freemarker.core.Environment.visit(Environment.java:221) at
freemarker.core.Environment.process(Environment.java:199) at
freemarker.template.Template.process(Template.java:259) at
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:157)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:572) at
org.apache.struts2.components.UIBean.end(UIBean.java:526) at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspx_meth_s_005foptiontransferselect_005f0(UserDefinedInfo_jsp.java:737)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspx_meth_s_005fform_005f1(UserDefinedInfo_jsp.java:651)
at
org.apache.jsp.pages.frame.system.UserDefinedInfo_jsp._jspService(UserDefinedInfo_jsp.java:387)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
at
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at
com.gimis.gframe.system.interceptor.QueryInterceptor.doIntercept(QueryInterceptor.java:75)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.gframe.system.interceptor.OperationLogInterceptor.doIntercept(OperationLogInterceptor.java:62)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.core.interceptor.TranceActionInterceptor.doIntercept(TranceActionInterceptor.java:45)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.core.interceptor.ExceptionInterceptor.doIntercept(ExceptionInterceptor.java:44)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.gimis.gframe.system.interceptor.SecurityInterceptor.doIntercept(SecurityInterceptor.java:89)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:93)
at org.apache.cata
Python, all possible combinations of numbers betweens 2 lists
Python, all possible combinations of numbers betweens 2 lists
i'm new to python and i would like some guidance with a problem i'm having.
Let's say you have two lists, with same length and filled with numbers
x=[0,1,2,3]
y=[0,4,5,6]
How can Python calculate the numbers between the numbers in the list at
the same position. So for this example.
[0,1,2,3]
[0,2,2,3]
[0,3,2,3]
[0,4,2,3]
[0,1,3,3]
...
I hoped someone with more experience would have some insight in this
matter. Thank you for your time and thoughts.
i'm new to python and i would like some guidance with a problem i'm having.
Let's say you have two lists, with same length and filled with numbers
x=[0,1,2,3]
y=[0,4,5,6]
How can Python calculate the numbers between the numbers in the list at
the same position. So for this example.
[0,1,2,3]
[0,2,2,3]
[0,3,2,3]
[0,4,2,3]
[0,1,3,3]
...
I hoped someone with more experience would have some insight in this
matter. Thank you for your time and thoughts.
Script stopping when storing a session var in a javascript var
Script stopping when storing a session var in a javascript var
I am getting ~ 2k cities name from my Database that I am storing in a
session variable, then I am trying to convert my session variable into a
javascript variable but my code seem to crash
Code for session variable
$sql = "SELECT nom FROM Villes ORDER BY nbSearch";
try
{ $resultat = $bd->Select($sql); }
catch(Exception $e)
{ echo $e->getMessage(); }
if(count($resultat) != 0)
$_SESSION['villeDB'] = $resultat;
echo count($resultat)."<br/>";
php to javascript
var availableTags = '<?php echo json_encode($_SESSION['villeDB']) ?>';
I need to store each city name into that kind of JavaScript var
var availableTags = [];
I am getting ~ 2k cities name from my Database that I am storing in a
session variable, then I am trying to convert my session variable into a
javascript variable but my code seem to crash
Code for session variable
$sql = "SELECT nom FROM Villes ORDER BY nbSearch";
try
{ $resultat = $bd->Select($sql); }
catch(Exception $e)
{ echo $e->getMessage(); }
if(count($resultat) != 0)
$_SESSION['villeDB'] = $resultat;
echo count($resultat)."<br/>";
php to javascript
var availableTags = '<?php echo json_encode($_SESSION['villeDB']) ?>';
I need to store each city name into that kind of JavaScript var
var availableTags = [];
data structure in c that will hold an unknown length of cstrings and have the ability to remove them latter
data structure in c that will hold an unknown length of cstrings and have
the ability to remove them latter
In C what's the best data structure for storing an unknown amount of
values then removing many? I'm reading a file and each line is stored as a
c string in some larger data structure. Each line is probably less than 20
characters long and one example file has 300000 lines. Whatever
datastructure I'm going to use will only grow in size at it's initial
creation; from there it will only shrink in size. What would I use? In
Java I would use ArrayList or maybe Vector. Could a dynamic array work and
if yes how would it look like?
char aLine[21];
char *data = malloc(aLine);
fp = fopen("datafile", "r");
if(fp== NULL)
exit(EXIT_FAILURE);
while(fscanf(fp, "%20s", aLine) == 1)
{
data = aLine;
realloc(data, sizeof(data)+sizeof(aLine));
}
I've only seen
the ability to remove them latter
In C what's the best data structure for storing an unknown amount of
values then removing many? I'm reading a file and each line is stored as a
c string in some larger data structure. Each line is probably less than 20
characters long and one example file has 300000 lines. Whatever
datastructure I'm going to use will only grow in size at it's initial
creation; from there it will only shrink in size. What would I use? In
Java I would use ArrayList or maybe Vector. Could a dynamic array work and
if yes how would it look like?
char aLine[21];
char *data = malloc(aLine);
fp = fopen("datafile", "r");
if(fp== NULL)
exit(EXIT_FAILURE);
while(fscanf(fp, "%20s", aLine) == 1)
{
data = aLine;
realloc(data, sizeof(data)+sizeof(aLine));
}
I've only seen
Friday, 27 September 2013
putting multiple arrays into one single Liastbox
putting multiple arrays into one single Liastbox
I am trying to put multi arrays into a single listbox. Below is the code.
It works well when I make every output go into its own listBox but I am
trying to but them all in one listbox with the current headings. Can
someone help? One last thing, I would also like the duplicate values to go
into another column but don't know how. All I can due is just eliminate
the duplicates (want to go above and beyond and show what numbers were
eliminated)
Public Class Form1
Dim randomNum As New Random()
Dim SampleArray(19) As Integer
Dim aryNums() As Integer = SampleArray
Dim distinctNums = SampleArray.Distinct()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox1.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox2.Items.Add(SampleArray(i))
Next
For Each num In distinctNums
ListBox3.Items.Add(num.ToString())
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ListBox4.Items.Add("Index" & vbTab & "Random" & vbTab & "Sorted" &
vbTab & "Unique")
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox4.Items.Add(i & vbTab & SampleArray(i).ToString)
'ListBox4.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox4.Items.Add(vbTab & vbTab & SampleArray(i))
Next
For Each num In distinctNums
ListBox4.Items.Add(vbTab & vbTab & vbTab & num.ToString())
Next
End Sub
End Class
I am trying to put multi arrays into a single listbox. Below is the code.
It works well when I make every output go into its own listBox but I am
trying to but them all in one listbox with the current headings. Can
someone help? One last thing, I would also like the duplicate values to go
into another column but don't know how. All I can due is just eliminate
the duplicates (want to go above and beyond and show what numbers were
eliminated)
Public Class Form1
Dim randomNum As New Random()
Dim SampleArray(19) As Integer
Dim aryNums() As Integer = SampleArray
Dim distinctNums = SampleArray.Distinct()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox1.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox2.Items.Add(SampleArray(i))
Next
For Each num In distinctNums
ListBox3.Items.Add(num.ToString())
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ListBox4.Items.Add("Index" & vbTab & "Random" & vbTab & "Sorted" &
vbTab & "Unique")
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox4.Items.Add(i & vbTab & SampleArray(i).ToString)
'ListBox4.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox4.Items.Add(vbTab & vbTab & SampleArray(i))
Next
For Each num In distinctNums
ListBox4.Items.Add(vbTab & vbTab & vbTab & num.ToString())
Next
End Sub
End Class
In EJB conatainer, how to manage MDB, Will it create one thread for one MDB?
In EJB conatainer, how to manage MDB, Will it create one thread for one MDB?
MDB has to waiting for message to arraive, so it must to do something
"waiting" then block the running thread.
so, In EJB conatainer, how to manage MDB, Will it create one thread for
one MDB?
MDB has to waiting for message to arraive, so it must to do something
"waiting" then block the running thread.
so, In EJB conatainer, how to manage MDB, Will it create one thread for
one MDB?
How to visualize data in paraview with fortran
How to visualize data in paraview with fortran
I'm sorry I'm quite new to fortran therefore I don't know if this is out
of question. But I'd like to ask you for help. I wrote a program in
fortran which calculates molecular (basicaly their centers in 3d space -
xyz) movements. I'd like to visualize these data in ParaView, which I'm
capabl of. My programs output is VTK file which I can load into ParaView
and see everything I need clearly. But I'd like to somehow make this
process autonomous.
Basicaly I'd like to do computations and after some steps I'd like to
visualize molecules with ParaaView, take a screenshot from certain angle
save images as png (or any other img format which ParaView supports).
Because of a high number of iterations I can't do this myself, therefore I
thought about incorporating some kind of script into my fortran code or
any other way to make this happen, but I don't even know if this is
possible or how?
I do really hope you can help me I'm in a pinch here, I'm quite new to
fortran I hope I'm not asking for impossible.
I'd like to thank you very much for any help you can provide me with. (I'm
not asking for a prepared script, but for some hint/guide how to do this
if possible, but I'm not against examples either).
I'm sorry I'm quite new to fortran therefore I don't know if this is out
of question. But I'd like to ask you for help. I wrote a program in
fortran which calculates molecular (basicaly their centers in 3d space -
xyz) movements. I'd like to visualize these data in ParaView, which I'm
capabl of. My programs output is VTK file which I can load into ParaView
and see everything I need clearly. But I'd like to somehow make this
process autonomous.
Basicaly I'd like to do computations and after some steps I'd like to
visualize molecules with ParaaView, take a screenshot from certain angle
save images as png (or any other img format which ParaView supports).
Because of a high number of iterations I can't do this myself, therefore I
thought about incorporating some kind of script into my fortran code or
any other way to make this happen, but I don't even know if this is
possible or how?
I do really hope you can help me I'm in a pinch here, I'm quite new to
fortran I hope I'm not asking for impossible.
I'd like to thank you very much for any help you can provide me with. (I'm
not asking for a prepared script, but for some hint/guide how to do this
if possible, but I'm not against examples either).
Convert Hex to Byte with big string
Convert Hex to Byte with big string
I tried the different ways to convert hex to byte, there are four methods
in the code, three of them i comment it out, only one there is no error
when i run it, but i confused that when i repeated to run the code, it
gave me the different result (should be generate "byte").
There is a question is when i use "method1", it gave me the result (byte),
but once i changed to "method2", it will not generate the result, i dont
know why. I thought it should generate same result, when i have same
string.
public class Convert {
/**
* @param args
* @throws IOException
*/
// String everything;
public static void main(String[] args) throws IOException {
//String everything;
// TODO Auto-generated method stub
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("C:\\TEMP1\\Doctor.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
StringBuilder sb = new StringBuilder();
String line = null;
try {
line = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
//*********Method 1****************
//String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
//byte[] b = new BigInteger(r,16).toByteArray();
//System.out.println("Byte for public key: "+b);
//*********Method 2****************
//String r2 = sb.toString();
//System.out.println("Doctor contect file: "+r2);
//byte[] b = new BigInteger(r2,16).toByteArray();
//System.out.println("Byte for public key: "+b);
//********Method 3*****************
String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
int len = r.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(r.charAt(i), 16) << 4)
+ Character.digit(r.charAt(i+1), 16));
System.out.println(data);
}
//********Method4******************
/*
String r2 = sb.toString();
int len = r2.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(r2.charAt(i), 16)
<< 4)
+ Character.digit(r2.charAt(i+1), 16));
System.out.println(data);
}
*/
//String r=everything;
// String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
// double convert=Double.parseDouble(r);
// long convert=(long)(Integer.parseInt(r,32)&0xFF);
// byte convert=Byte.parseByte(r,32);
// byte convert=Integer.parseInt(everything,16);
// System.out.println("Byte for public key: "+convert);
} finally {
br.close();
}
}
}
I tried the different ways to convert hex to byte, there are four methods
in the code, three of them i comment it out, only one there is no error
when i run it, but i confused that when i repeated to run the code, it
gave me the different result (should be generate "byte").
There is a question is when i use "method1", it gave me the result (byte),
but once i changed to "method2", it will not generate the result, i dont
know why. I thought it should generate same result, when i have same
string.
public class Convert {
/**
* @param args
* @throws IOException
*/
// String everything;
public static void main(String[] args) throws IOException {
//String everything;
// TODO Auto-generated method stub
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("C:\\TEMP1\\Doctor.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
StringBuilder sb = new StringBuilder();
String line = null;
try {
line = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
//*********Method 1****************
//String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
//byte[] b = new BigInteger(r,16).toByteArray();
//System.out.println("Byte for public key: "+b);
//*********Method 2****************
//String r2 = sb.toString();
//System.out.println("Doctor contect file: "+r2);
//byte[] b = new BigInteger(r2,16).toByteArray();
//System.out.println("Byte for public key: "+b);
//********Method 3*****************
String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
int len = r.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(r.charAt(i), 16) << 4)
+ Character.digit(r.charAt(i+1), 16));
System.out.println(data);
}
//********Method4******************
/*
String r2 = sb.toString();
int len = r2.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(r2.charAt(i), 16)
<< 4)
+ Character.digit(r2.charAt(i+1), 16));
System.out.println(data);
}
*/
//String r=everything;
// String
r="1ee079746828d7c6f9af46f93c1ef2555ff4b14b2378ad53a258d18dc6a8363fb57f3448783833722bd9ef291ba53153afca31a96de404755e78f68b76fd5a77e4be3b984ea25244842e92a8ed40da1f1a588fb3da26b8bc21d74cd8476534f26ee454df086567c4d7cf3334f794cede41a9b051a5c393a35584afcf";
// double convert=Double.parseDouble(r);
// long convert=(long)(Integer.parseInt(r,32)&0xFF);
// byte convert=Byte.parseByte(r,32);
// byte convert=Integer.parseInt(everything,16);
// System.out.println("Byte for public key: "+convert);
} finally {
br.close();
}
}
}
Maven archetype generation
Maven archetype generation
I use mvn archetype:create-from-project commant and I do not know hove to
castomize my archetype, for example I have next prop xml file:
<?xml version="1.0" encoding="utf-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
<portlet>
<portlet-name>MyPortletName</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/context/portlet-context.xml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>My portlet</title>
</portlet-info>
</portlet>
</portlet-app>
And I want pass portlet name and title as parametrs when generate
arcetype, and some lines in xml will changed to this, for example:
...
<portlet-name>${portletName}</portlet-name>
....
<portlet-info>
<title>${portletTitle}</title>
</portlet-info>
So want full castomized template, it is possible?
I use mvn archetype:create-from-project commant and I do not know hove to
castomize my archetype, for example I have next prop xml file:
<?xml version="1.0" encoding="utf-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0">
<portlet>
<portlet-name>MyPortletName</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/context/portlet-context.xml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>My portlet</title>
</portlet-info>
</portlet>
</portlet-app>
And I want pass portlet name and title as parametrs when generate
arcetype, and some lines in xml will changed to this, for example:
...
<portlet-name>${portletName}</portlet-name>
....
<portlet-info>
<title>${portletTitle}</title>
</portlet-info>
So want full castomized template, it is possible?
iOS custom CALayer class CRASH
iOS custom CALayer class CRASH
I'm trying to create custom drawn icons with this technique: Drawing
animated shapes and text in Core Animation layers
However that StarLayer sample is crashing (Message sent to deallocated
instance) and I can't find out what's wrong. StarLayer gets deallocated
somehow. I'm using ARC.
StarLayer is subclass of NSObject and it implements method:
- (void)drawLayer:(CALayer *)theLayer
inContext:(CGContextRef)context
Is that right approach to create custom icons using CALayers ?
I'm trying to create custom drawn icons with this technique: Drawing
animated shapes and text in Core Animation layers
However that StarLayer sample is crashing (Message sent to deallocated
instance) and I can't find out what's wrong. StarLayer gets deallocated
somehow. I'm using ARC.
StarLayer is subclass of NSObject and it implements method:
- (void)drawLayer:(CALayer *)theLayer
inContext:(CGContextRef)context
Is that right approach to create custom icons using CALayers ?
Thursday, 26 September 2013
How to change the default language of connect.microsoft.com?
How to change the default language of connect.microsoft.com?
I don't know whether or not this question is fitting SO.
I have found some bugs of the VC++ compiler, and I want to summit them to
Microsoft's official website: connect.microsoft.com
However, I am being located at China, so connect.microsoft.com always
returns web pages in Chinese. But I'm more familiar with English than with
Chinese. So I want to change the web pages' language to English.
The bad thing is: connect.microsoft.com will first determine the country
the client's IP belongs to, and next use the country's default language to
return web pages.
My question is: How to change the web pages' language of
connect.microsoft.com to any other one, say, English, German, Janpanese,
etc.?
I don't know whether or not this question is fitting SO.
I have found some bugs of the VC++ compiler, and I want to summit them to
Microsoft's official website: connect.microsoft.com
However, I am being located at China, so connect.microsoft.com always
returns web pages in Chinese. But I'm more familiar with English than with
Chinese. So I want to change the web pages' language to English.
The bad thing is: connect.microsoft.com will first determine the country
the client's IP belongs to, and next use the country's default language to
return web pages.
My question is: How to change the web pages' language of
connect.microsoft.com to any other one, say, English, German, Janpanese,
etc.?
Wednesday, 25 September 2013
Using Google API in PHP
Using Google API in PHP
----------Can Any body tell how to use Google API in PHP?-----------
Please give the instructions in PHP..........
----------Can Any body tell how to use Google API in PHP?-----------
Please give the instructions in PHP..........
Thursday, 19 September 2013
Getting Started with CEF for the windows api
Getting Started with CEF for the windows api
I'm trying to get started using chromium embedded using the windows api. I
have managed to open and run the example project, but I have no clue of
where to go from there. The CEF wiki has no examples of use on windows,
and while I have found tutorials for gtk+ (
https://github.com/aphistic/cef3barebones ), it isn't going to help me
much with integration in the windows api. I am in the process of studying
the example application, but it is very complicated compared for the basic
functionality I a looking for Anybody have any adivice on what to do to
try an learn CEF on windows? Is there any tutorials on windows that I
haven't found yet?
Thanks for the help.
I'm trying to get started using chromium embedded using the windows api. I
have managed to open and run the example project, but I have no clue of
where to go from there. The CEF wiki has no examples of use on windows,
and while I have found tutorials for gtk+ (
https://github.com/aphistic/cef3barebones ), it isn't going to help me
much with integration in the windows api. I am in the process of studying
the example application, but it is very complicated compared for the basic
functionality I a looking for Anybody have any adivice on what to do to
try an learn CEF on windows? Is there any tutorials on windows that I
haven't found yet?
Thanks for the help.
POST request does not work
POST request does not work
I want to create a POST request to a website. For this I record the POST
request with an addon for FireFox. I got this output:
https://XXXXXXXXXX/anmeldung.fcgi
POST /cgi/anmeldung.fcgi HTTP/1.1
Host: muenster.hochschulsport-nrw.de
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101
Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://YYYYYYYYYY/index.html
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 12
name=cilenco
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Date: Thu, 19 Sep 2013 21:15:08 GMT
Server: lighttpd/1.4.31
Now I want to recreate the POST Request with the Simple REST Client for
Google Chrome. I set the URL to the first line and the data to
name=cilenco but it does not work. I get a wrong response. Do you have any
ideas why or do I have to use more information from above?
I want to create a POST request to a website. For this I record the POST
request with an addon for FireFox. I got this output:
https://XXXXXXXXXX/anmeldung.fcgi
POST /cgi/anmeldung.fcgi HTTP/1.1
Host: muenster.hochschulsport-nrw.de
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101
Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://YYYYYYYYYY/index.html
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 12
name=cilenco
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Date: Thu, 19 Sep 2013 21:15:08 GMT
Server: lighttpd/1.4.31
Now I want to recreate the POST Request with the Simple REST Client for
Google Chrome. I set the URL to the first line and the data to
name=cilenco but it does not work. I get a wrong response. Do you have any
ideas why or do I have to use more information from above?
Seperating list by decimal in Python
Seperating list by decimal in Python
Here is my current list:
x = [1.0, 0.0, 3.5, 1.2, 5.4]
and here is what I want:
newx = [1, 0, 0, 0, 3, 5, 1, 2, 5, 4]
I just need to split the list at the decimal point and do not want any
extra zeros added to the new list. Seems like there should be a simple
solution I just don't know about since I am so new.
Here is my current list:
x = [1.0, 0.0, 3.5, 1.2, 5.4]
and here is what I want:
newx = [1, 0, 0, 0, 3, 5, 1, 2, 5, 4]
I just need to split the list at the decimal point and do not want any
extra zeros added to the new list. Seems like there should be a simple
solution I just don't know about since I am so new.
shell bit shifting producing different numbers
shell bit shifting producing different numbers
in my local machines bash when I run:
echo $((192 << 24))
3221225472
but on my embedded targets busy box SHELL I get something else:
echo $((192 << 24))
-1073741824
it works when I left shift by a smaller number though. Is there a max
range for integers in shell?
in my local machines bash when I run:
echo $((192 << 24))
3221225472
but on my embedded targets busy box SHELL I get something else:
echo $((192 << 24))
-1073741824
it works when I left shift by a smaller number though. Is there a max
range for integers in shell?
On App update custom plist file will get updated or do we need to do some thing?
On App update custom plist file will get updated or do we need to do some
thing?
I have an app in appstore now im going to push out an update of app, Im
having a custom Plist file with set of values in my application bundle,
and these values are been modified from the version which is in production
and in addition even more key value pairs are added in to this file.
Now my doubt is on updating this app to appStore will the update process
automatically overrides(updates) my new plist file on top of existing one
or do we need to do some work around like how we do for database changes
like coredata migration and all?
thing?
I have an app in appstore now im going to push out an update of app, Im
having a custom Plist file with set of values in my application bundle,
and these values are been modified from the version which is in production
and in addition even more key value pairs are added in to this file.
Now my doubt is on updating this app to appStore will the update process
automatically overrides(updates) my new plist file on top of existing one
or do we need to do some work around like how we do for database changes
like coredata migration and all?
Strange performance issues on iOS7
Strange performance issues on iOS7
I'm testing my app on iPhone 5 which runs iOS 7. Just for test purposes I
run 1000 iterations of cv::integral.
When on iOS 6 the results range were from 0.0005 to 0.0006 sec/iteration.
But on iOS 7 the timing range may differ from 0.0004 to 0.002
sec/iteration. A huge scatter.
It seems to be the OS scheduling bug. But is there any workaround, cause
my app heavily depends on performance?
I'm testing my app on iPhone 5 which runs iOS 7. Just for test purposes I
run 1000 iterations of cv::integral.
When on iOS 6 the results range were from 0.0005 to 0.0006 sec/iteration.
But on iOS 7 the timing range may differ from 0.0004 to 0.002
sec/iteration. A huge scatter.
It seems to be the OS scheduling bug. But is there any workaround, cause
my app heavily depends on performance?
Error installing pg through capistrano deployment
Error installing pg through capistrano deployment
I have rails 2.3.8 app I have pg in my gemfile but showing error after
deployment
servers: ["apphost"]
[apphost] executing command
** [out :: apphost] Gem::Installer::ExtensionBuildError: ERROR: Failed to
build gem native extension.
** [out :: apphost]
** [out :: apphost] /usr/local/bin/ruby extconf.rb
** [out :: apphost] checking for pg_config... no
** [out :: apphost] No pg_config... trying anyway. If building fails,
please try again with
** [out :: apphost] --with-pg-config=/path/to/pg_config
** [out :: apphost] checking for libpq-fe.h... no
** [out :: apphost] Can't find the 'libpq-fe.h header
** [out :: apphost] *** extconf.rb failed ***
** [out :: apphost] Could not create Makefile due to some reason,
probably lack of
** [out :: apphost] necessary libraries and/or headers. Check the
mkmf.log file for more
** [out :: apphost] details. You may need configuration options.
** [out :: apphost]
** [out :: apphost] Provided configuration options:
I have rails 2.3.8 app I have pg in my gemfile but showing error after
deployment
servers: ["apphost"]
[apphost] executing command
** [out :: apphost] Gem::Installer::ExtensionBuildError: ERROR: Failed to
build gem native extension.
** [out :: apphost]
** [out :: apphost] /usr/local/bin/ruby extconf.rb
** [out :: apphost] checking for pg_config... no
** [out :: apphost] No pg_config... trying anyway. If building fails,
please try again with
** [out :: apphost] --with-pg-config=/path/to/pg_config
** [out :: apphost] checking for libpq-fe.h... no
** [out :: apphost] Can't find the 'libpq-fe.h header
** [out :: apphost] *** extconf.rb failed ***
** [out :: apphost] Could not create Makefile due to some reason,
probably lack of
** [out :: apphost] necessary libraries and/or headers. Check the
mkmf.log file for more
** [out :: apphost] details. You may need configuration options.
** [out :: apphost]
** [out :: apphost] Provided configuration options:
Wednesday, 18 September 2013
int fun(void **args) and on calling of function pass the argument fun(args),
int fun(void **args) and on calling of function pass the argument fun(args),
I am using some inbuilt function fun(void **args) and to call this
function passing argument fun(args); so what is mean of void **args and
how to check what does value args have in C.
Please help
Thanks in advance.
I am using some inbuilt function fun(void **args) and to call this
function passing argument fun(args); so what is mean of void **args and
how to check what does value args have in C.
Please help
Thanks in advance.
Websocket Mobile Data Consumption
Websocket Mobile Data Consumption
Will I incur more charges over my mobile data bill using WebSocket versus
an ordinary request?
I will be sending map coordinates from the client (using a phone) via
WebSocket to a server which would then be tracked every nth second(s).
Thank you.
Will I incur more charges over my mobile data bill using WebSocket versus
an ordinary request?
I will be sending map coordinates from the client (using a phone) via
WebSocket to a server which would then be tracked every nth second(s).
Thank you.
XML view with relative percentages
XML view with relative percentages
I've been creating Android apps for well over 2 years, I've created games
and animated live wallpapers as well as using some basic XML to create
some settings. I've mainly used my own custom views written in JAVA using
the canvas class. Now I want to move across to XML views because of the
speed of development it offers.
Anyhow, I'm trying to figure out how to create an Android XML view using
percentages of the screen instead of DP.
Link to what I'm trying to say:
http://imgur.com/FZemLXy
What would be the best way of doing this? And can someone give me an
example? It needs to have the same percentages on every screen it's
displayed on.
I've been creating Android apps for well over 2 years, I've created games
and animated live wallpapers as well as using some basic XML to create
some settings. I've mainly used my own custom views written in JAVA using
the canvas class. Now I want to move across to XML views because of the
speed of development it offers.
Anyhow, I'm trying to figure out how to create an Android XML view using
percentages of the screen instead of DP.
Link to what I'm trying to say:
http://imgur.com/FZemLXy
What would be the best way of doing this? And can someone give me an
example? It needs to have the same percentages on every screen it's
displayed on.
iOS 7 : Disable UINavigationBar Translucency For Entire App
iOS 7 : Disable UINavigationBar Translucency For Entire App
Is there a way to disable UINavigationBar Translucency for an entire
application?
I'm aware that using [self.navigationController.navigationBar
setTranslucent:NO] can fix this issue for a single controller, but I have
a lot of UINavigationBars in my application and this is a pretty tedious
solution.
I've tried [[UINavigationBar appearance] setTranslucent:NO], but that
functionality is surprisingly not supported. Doing that results in
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** Illegal property type, c for appearance setter,
_installAppearanceSwizzlesForSetter:'
If I HAVE to, I can go through my entire app setting UINavigationBars to
disable translucency one by one, but there must be some more elegant
solution to this issue...
Is there a way to disable UINavigationBar Translucency for an entire
application?
I'm aware that using [self.navigationController.navigationBar
setTranslucent:NO] can fix this issue for a single controller, but I have
a lot of UINavigationBars in my application and this is a pretty tedious
solution.
I've tried [[UINavigationBar appearance] setTranslucent:NO], but that
functionality is surprisingly not supported. Doing that results in
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** Illegal property type, c for appearance setter,
_installAppearanceSwizzlesForSetter:'
If I HAVE to, I can go through my entire app setting UINavigationBars to
disable translucency one by one, but there must be some more elegant
solution to this issue...
Is there an equivalent to @property for containers in Python?
Is there an equivalent to @property for containers in Python?
I'm writing a simplified wrapper class in Python for an AWS module (Boto,
specifically). Several times in this process I've used @property to avoid
special "getter" and "setter" methods in my library - I'm told that this
is the more pythonic way to do it. When using the class, the programmer
call the methods as if they were simple objects, like this:
myclass.myprop = 5 # sends "5" to myprop's setter function
result = myclass.myprop # calls myprop's getter function and stores the
result
But I'm also dealing with several sets of objects - name/value pairs of
tags, for example - that I would like to access as if they were held in a
container, possibly a dictionary or a list. Taking the tag example:
myclass.tags["newkey"] = "newvalue" # runs a function that applies tag
in AWS
result = myclass.tags["newkey"] # accesses AWS to get value of
"newkey" tag
From what I'm seeing, it looks like it would be possible to do this by
subclassing dict, but I feel like I'm missing something here. What is the
most pythonic way to create an interface like this?
I'm writing a simplified wrapper class in Python for an AWS module (Boto,
specifically). Several times in this process I've used @property to avoid
special "getter" and "setter" methods in my library - I'm told that this
is the more pythonic way to do it. When using the class, the programmer
call the methods as if they were simple objects, like this:
myclass.myprop = 5 # sends "5" to myprop's setter function
result = myclass.myprop # calls myprop's getter function and stores the
result
But I'm also dealing with several sets of objects - name/value pairs of
tags, for example - that I would like to access as if they were held in a
container, possibly a dictionary or a list. Taking the tag example:
myclass.tags["newkey"] = "newvalue" # runs a function that applies tag
in AWS
result = myclass.tags["newkey"] # accesses AWS to get value of
"newkey" tag
From what I'm seeing, it looks like it would be possible to do this by
subclassing dict, but I feel like I'm missing something here. What is the
most pythonic way to create an interface like this?
Oracle - Update string to replace only the last character
Oracle - Update string to replace only the last character
I have the following string in an Oracle 9i database:
A,B,C,
I need to replace all instances of ',' when it is the last item in the
string. I have come up with the following statement but it deletes
everything in the field not just the comma. Any suggestions?
UPDATE table SET column = REPLACE(SUBSTR(column, -1, 1), ',', '');
I have the following string in an Oracle 9i database:
A,B,C,
I need to replace all instances of ',' when it is the last item in the
string. I have come up with the following statement but it deletes
everything in the field not just the comma. Any suggestions?
UPDATE table SET column = REPLACE(SUBSTR(column, -1, 1), ',', '');
to show error message beside textbox in javascript
to show error message beside textbox in javascript
Please correct the below code it is not working as expected i.e, i need a
error message to be shown just beside the textfield in the form when user
enters an invalid name Also i need help on validation methods for this
code?
<style type="text/css">
.container {
margin:auto;
width:30%;
}
body {
background: url(1.jpg) no-repeat;
background-size: 100%;
}
</style>
<script type="text/javascript">
function LockName(){
if(locker.lock.value.length==0)
document.getElementById('errfn').innerHTML="this is invalid name";
}
</script>
<div class="container">
<h1>Welcome to Locker</h1>
<form name="locker" action="" onsubmit="return Validateform()"
method="post">
<table>
<tr>
<td align="right"><h1>Lock name:</h1></td>
<td align="left"><h1><input type="text" maxlength="8" name="lock"
onblur="LockName()" ><div id="errfn"> </div>
</h1></td>
</tr><br>
<tr>
<td align="right"><h1>Key:</h1></td>
<td align="left"><h1><input type="text" ></h1></td>
</tr><br>
<tr>
<td align="right"></td>
<td align="left"><input type="submit" value="Submit"></td>
</tr><br>
</table>
</form> <br/>
</head>
<body>
</body>
</html>
Please correct the below code it is not working as expected i.e, i need a
error message to be shown just beside the textfield in the form when user
enters an invalid name Also i need help on validation methods for this
code?
<style type="text/css">
.container {
margin:auto;
width:30%;
}
body {
background: url(1.jpg) no-repeat;
background-size: 100%;
}
</style>
<script type="text/javascript">
function LockName(){
if(locker.lock.value.length==0)
document.getElementById('errfn').innerHTML="this is invalid name";
}
</script>
<div class="container">
<h1>Welcome to Locker</h1>
<form name="locker" action="" onsubmit="return Validateform()"
method="post">
<table>
<tr>
<td align="right"><h1>Lock name:</h1></td>
<td align="left"><h1><input type="text" maxlength="8" name="lock"
onblur="LockName()" ><div id="errfn"> </div>
</h1></td>
</tr><br>
<tr>
<td align="right"><h1>Key:</h1></td>
<td align="left"><h1><input type="text" ></h1></td>
</tr><br>
<tr>
<td align="right"></td>
<td align="left"><input type="submit" value="Submit"></td>
</tr><br>
</table>
</form> <br/>
</head>
<body>
</body>
</html>
How to get week start dates and week number of each week in a year considering start day of the week is Monday in python?
How to get week start dates and week number of each week in a year
considering start day of the week is Monday in python?
How can I get week start dates of each week in a year, considering start
day of the week is Monday in python?
This assumes start day is Sunday:
>>>import datetime as datetime
>>>dt = datetime .date(2013,12,30)
>>>dt.isocalendar()[1]
1
However, result shouldn't be 1, because 30-12-2013 is still in 2013.
considering start day of the week is Monday in python?
How can I get week start dates of each week in a year, considering start
day of the week is Monday in python?
This assumes start day is Sunday:
>>>import datetime as datetime
>>>dt = datetime .date(2013,12,30)
>>>dt.isocalendar()[1]
1
However, result shouldn't be 1, because 30-12-2013 is still in 2013.
'NoneType' object is not subscriptable?
'NoneType' object is not subscriptable?
list1 = ["name1", "info1", 10]
list2 = ["name2", "info2", 30]
list3 = ["name3", "info3", 50]
MASTERLIST = [list1, list2, list3]
def printer(list):
print ("Available Lists:")
listlen = (len(list))
for x in range(listlen):
print (list[x])[0]
This code is returning the --'NoneType' object is not subscriptable--
error when I try and run printer with MASTERLIST. What did I do wrong?
list1 = ["name1", "info1", 10]
list2 = ["name2", "info2", 30]
list3 = ["name3", "info3", 50]
MASTERLIST = [list1, list2, list3]
def printer(list):
print ("Available Lists:")
listlen = (len(list))
for x in range(listlen):
print (list[x])[0]
This code is returning the --'NoneType' object is not subscriptable--
error when I try and run printer with MASTERLIST. What did I do wrong?
Tuesday, 17 September 2013
Sinatra - Calling a method based on the parameter passed
Sinatra - Calling a method based on the parameter passed
I have this specific route I want to implement in Sinatra:
post '/activate/:model/:id/?' do
model.activate stuff
basically what happens here is that I get the model name using
Module.const_get. I then call the activate method on the object. Now I
want to add a deactivate method, I can duplicate the code and just modify
it to be deactivate, but it's not very DRY-ish. I should probably use a
Regex, right? How do I "dynamically call a method" (aka call deactivate or
activate depending on the route?
I have this specific route I want to implement in Sinatra:
post '/activate/:model/:id/?' do
model.activate stuff
basically what happens here is that I get the model name using
Module.const_get. I then call the activate method on the object. Now I
want to add a deactivate method, I can duplicate the code and just modify
it to be deactivate, but it's not very DRY-ish. I should probably use a
Regex, right? How do I "dynamically call a method" (aka call deactivate or
activate depending on the route?
Getting linking error: Some Makefile Issue
Getting linking error: Some Makefile Issue
I am trying to add Makefiles to my embedded project, Have tried creating a
small project but am getting link error when linking a file in child
directory, Can you guys please help The error is:
arm-linux-gnueabi-gcc -c -o hellofun.o hellofun.c -I. -I./include
hellofun.c: In function 'myPrintHelloMake':
hellofun.c:6:14: warning: initialization makes pointer from integer
without a cast [enabled by default]
hellofun.c:7:24: warning: initialization makes pointer from integer
without a cast [enabled by default]
arm-linux-gnueabi-gcc -c -o hellomake.o hellomake.c -I. -I./include
arm-linux-gnueabi-gcc -c -o folder/func2.o folder/func2.c -I. -I./include
arm-linux-gnueabi-gcc hellofun.o hellomake.o folder/func2.o -o hm
hellofun.o: In function `myPrintHelloMake':
hellofun.c:(.text+0xc): undefined reference to `func2'
collect2: ld returned 1 exit status
make: *** [hm] Error 1
The source files rootdir/Makefile:
1 CC=arm-linux-gnueabi-gcc
2 CFLAGS=-I. -I./include
3 SOURCES=hellofun.c hellomake.c
4 OBJECTS=$(SOURCES:.c=.o)
5 OBJECTS+=folder/func2.o
6 TARGET=hm
7 DEPS = hellomake.h
8
9 %.o: %.c $(DEPS)
10 $(CC) -c -o $@ $< $(CFLAGS)
11
12 clean:
13 rm -rf *.o hellomake folder/*.o
14
15 all: $(SOURCES) $(TARGET)
16
17 $(TARGET): $(OBJECTS)
18 $(CC) $(OBJECTS) -o $@
19
folder/Makefile:
1 SOURCES=$(wildcard *.c)
2 OBJECTS=$(SOURCES:.c=.o)
3 TARGET=func2.o
4 %.o: %.c
5 $(CC) -c -o $@ $< $(CFLAGS)
6
7 clean:
8 rm -rf *.o
9
10 $(TARGET): $(OBJECTS)
11
~
Code Files: hellomake.c
1 #include "hellomake.h"
2
3 int main()
4 {
5 myPrintHelloMake();
6 return 0;
7 }
CodeFile: hellofun.c
1 #include "include/func2.h"
2
3 void myPrintHelloMake(void)
4 {
5 int i=0;
6 char* str = func2();
7 volatile char *addr = 0x80000000;
8
9 while(str[i]!='\0') {
10 addr[i] = str[i];
11 i++;
12 }
13
14 }
CodeFile: folder/func2.c
1 char* showMsg()
2 {
3 return "Hello World";
4 }
~
~
I am trying to add Makefiles to my embedded project, Have tried creating a
small project but am getting link error when linking a file in child
directory, Can you guys please help The error is:
arm-linux-gnueabi-gcc -c -o hellofun.o hellofun.c -I. -I./include
hellofun.c: In function 'myPrintHelloMake':
hellofun.c:6:14: warning: initialization makes pointer from integer
without a cast [enabled by default]
hellofun.c:7:24: warning: initialization makes pointer from integer
without a cast [enabled by default]
arm-linux-gnueabi-gcc -c -o hellomake.o hellomake.c -I. -I./include
arm-linux-gnueabi-gcc -c -o folder/func2.o folder/func2.c -I. -I./include
arm-linux-gnueabi-gcc hellofun.o hellomake.o folder/func2.o -o hm
hellofun.o: In function `myPrintHelloMake':
hellofun.c:(.text+0xc): undefined reference to `func2'
collect2: ld returned 1 exit status
make: *** [hm] Error 1
The source files rootdir/Makefile:
1 CC=arm-linux-gnueabi-gcc
2 CFLAGS=-I. -I./include
3 SOURCES=hellofun.c hellomake.c
4 OBJECTS=$(SOURCES:.c=.o)
5 OBJECTS+=folder/func2.o
6 TARGET=hm
7 DEPS = hellomake.h
8
9 %.o: %.c $(DEPS)
10 $(CC) -c -o $@ $< $(CFLAGS)
11
12 clean:
13 rm -rf *.o hellomake folder/*.o
14
15 all: $(SOURCES) $(TARGET)
16
17 $(TARGET): $(OBJECTS)
18 $(CC) $(OBJECTS) -o $@
19
folder/Makefile:
1 SOURCES=$(wildcard *.c)
2 OBJECTS=$(SOURCES:.c=.o)
3 TARGET=func2.o
4 %.o: %.c
5 $(CC) -c -o $@ $< $(CFLAGS)
6
7 clean:
8 rm -rf *.o
9
10 $(TARGET): $(OBJECTS)
11
~
Code Files: hellomake.c
1 #include "hellomake.h"
2
3 int main()
4 {
5 myPrintHelloMake();
6 return 0;
7 }
CodeFile: hellofun.c
1 #include "include/func2.h"
2
3 void myPrintHelloMake(void)
4 {
5 int i=0;
6 char* str = func2();
7 volatile char *addr = 0x80000000;
8
9 while(str[i]!='\0') {
10 addr[i] = str[i];
11 i++;
12 }
13
14 }
CodeFile: folder/func2.c
1 char* showMsg()
2 {
3 return "Hello World";
4 }
~
~
postgresql transpose rows an columns misery
postgresql transpose rows an columns misery
I have gone through all of the similar topics and can't seem to solve my
problem. I have a table like this:
id[PK] key[PK] value
22 ingfs east1 22 storage stgeast1 23 ingfs east2 23 storage stgeast2 24
ingfs west3 24 storage stgwest3
I want to get:
ingfs storage
east1 stgeast1 east2 stgeast2 east3 stgeast3
I have tried the pivot table example but don't seem to be able to get
anything to work. Seems like this should be simple but I can't get my head
wrapped around it. Thanks in advance for any assistance.
rjl
I have gone through all of the similar topics and can't seem to solve my
problem. I have a table like this:
id[PK] key[PK] value
22 ingfs east1 22 storage stgeast1 23 ingfs east2 23 storage stgeast2 24
ingfs west3 24 storage stgwest3
I want to get:
ingfs storage
east1 stgeast1 east2 stgeast2 east3 stgeast3
I have tried the pivot table example but don't seem to be able to get
anything to work. Seems like this should be simple but I can't get my head
wrapped around it. Thanks in advance for any assistance.
rjl
Uncheck an html checkbox with for label
Uncheck an html checkbox with for label
I am using the following html to display a checkbox with an image:
Compare
I need to uncheck the checkbox in certain conditions. I am using the
following jquery : $('#111')[0].checked = false;
This works fine if I don't have the label. When I have the label, I don't
get any errors in console (either Chrome or Firefox), but the checkbox
does not uncheck.
I am using the following html to display a checkbox with an image:
Compare
I need to uncheck the checkbox in certain conditions. I am using the
following jquery : $('#111')[0].checked = false;
This works fine if I don't have the label. When I have the label, I don't
get any errors in console (either Chrome or Firefox), but the checkbox
does not uncheck.
R: Fitting a generalised logistic function
R: Fitting a generalised logistic function
I need some help fitting a generalised logistic function using R. For
reference, let's say the data looks roughly like this.
Initially, I tried nls using the following guide, however, I was having
trouble estimating initial parameters (i.e. receiving error messages; for
instance: singular gradient matrix at initial parameter estimates).
I next tried the package grofit (CRAN; viginette). Whilst I managed to
plot a line of best fit, it was poor as couldn't find a way to set the
lower asymptope to anything other but 0.
As I am not able to provide a working example, I don't expect a closed
solution, however, if someone could provide general advice (e.g. useful
packages, example code) that would be much appreciated.
Cheers
I need some help fitting a generalised logistic function using R. For
reference, let's say the data looks roughly like this.
Initially, I tried nls using the following guide, however, I was having
trouble estimating initial parameters (i.e. receiving error messages; for
instance: singular gradient matrix at initial parameter estimates).
I next tried the package grofit (CRAN; viginette). Whilst I managed to
plot a line of best fit, it was poor as couldn't find a way to set the
lower asymptope to anything other but 0.
As I am not able to provide a working example, I don't expect a closed
solution, however, if someone could provide general advice (e.g. useful
packages, example code) that would be much appreciated.
Cheers
Grid view to stay intact once imageview image is changed
Grid view to stay intact once imageview image is changed
Hi I am developing a game in android where in the alpha value is changed
once the image in the imageview and the image in the grid view matches. if
the number of matches are equal to 4, i need to change the image in the
imageview and again compare with the images in the grid view.
I change the image in the imageview using imageView.setImageResource(q);
The image gets changed but the grid view disappears. Could you please tell
me what I need to do for teh grid view to change intact?
I tried gridView.invalidateViews(); but in vain. I also created a new
imageadapter with the same context but it still did not work. Any help
would be really great!
package com.example.despicablemehunt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.Toast;
public class MainActivity extends Activity {
final public Integer[] mThumbIds = {
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4
};
int i=0;
int p=0;
final Integer q=0;
public Context mContext;
List<Integer> imagesArrayList = new
ArrayList<Integer>(Arrays.asList(mThumbIds));
Integer [] tempArrayList;
public static final Random rgenerator = new Random();
public static final Integer[] mImageIds =
{ R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3,R.drawable.icon4 };
@Override
protected void onCreate(Bundle savedInstanceState) {
final long time= System.currentTimeMillis();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Collections.shuffle(imagesArrayList);
tempArrayList = (Integer[])(imagesArrayList.toArray(new
Integer[imagesArrayList.size()]));
final GridView gridView = (GridView) findViewById(R.id.grid_view);
// Instance of ImageAdapter Class
gridView.setAdapter(new ImageAdapter(this));
final Integer q =
mImageIds[rgenerator.nextInt(mImageIds.length)];
final ImageView iv = (ImageView) findViewById(R.id.imageView1);
iv.setImageResource(q);
gridView.setOnItemClickListener(new OnItemClickListener() {
@SuppressLint("NewApi")
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
if(getResources().getDrawable(q).getConstantState().equals(getResources().getDrawable(tempArrayList[arg2]).getConstantState()))
{
if(p==5)
{
/*final long time1= System.currentTimeMillis();
if ((time1-time)> 20)
{
}*/
Toast.makeText(getApplicationContext(),
"DONE DONE DONE",
Toast.LENGTH_SHORT).show();
}
arg1.setAlpha((float) 0.4);
if((++i)== 4)
{
gridView.setAlpha((float)0.0);
p++;
final Integer q =
mImageIds[rgenerator.nextInt(mImageIds.length)];
ImageView imageView = (ImageView) iv;
imageView.setImageResource(q);
i=0;
gridView.invalidate();
}
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class ImageAdapter extends BaseAdapter {
// Keep all Images in array
// Constructor
public ImageAdapter(Context c){
mContext = c;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(tempArrayList[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
return imageView;
}
}
}``
Hi I am developing a game in android where in the alpha value is changed
once the image in the imageview and the image in the grid view matches. if
the number of matches are equal to 4, i need to change the image in the
imageview and again compare with the images in the grid view.
I change the image in the imageview using imageView.setImageResource(q);
The image gets changed but the grid view disappears. Could you please tell
me what I need to do for teh grid view to change intact?
I tried gridView.invalidateViews(); but in vain. I also created a new
imageadapter with the same context but it still did not work. Any help
would be really great!
package com.example.despicablemehunt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.Toast;
public class MainActivity extends Activity {
final public Integer[] mThumbIds = {
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4,
R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3, R.drawable.icon4
};
int i=0;
int p=0;
final Integer q=0;
public Context mContext;
List<Integer> imagesArrayList = new
ArrayList<Integer>(Arrays.asList(mThumbIds));
Integer [] tempArrayList;
public static final Random rgenerator = new Random();
public static final Integer[] mImageIds =
{ R.drawable.icon1, R.drawable.icon2,
R.drawable.icon3,R.drawable.icon4 };
@Override
protected void onCreate(Bundle savedInstanceState) {
final long time= System.currentTimeMillis();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Collections.shuffle(imagesArrayList);
tempArrayList = (Integer[])(imagesArrayList.toArray(new
Integer[imagesArrayList.size()]));
final GridView gridView = (GridView) findViewById(R.id.grid_view);
// Instance of ImageAdapter Class
gridView.setAdapter(new ImageAdapter(this));
final Integer q =
mImageIds[rgenerator.nextInt(mImageIds.length)];
final ImageView iv = (ImageView) findViewById(R.id.imageView1);
iv.setImageResource(q);
gridView.setOnItemClickListener(new OnItemClickListener() {
@SuppressLint("NewApi")
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
if(getResources().getDrawable(q).getConstantState().equals(getResources().getDrawable(tempArrayList[arg2]).getConstantState()))
{
if(p==5)
{
/*final long time1= System.currentTimeMillis();
if ((time1-time)> 20)
{
}*/
Toast.makeText(getApplicationContext(),
"DONE DONE DONE",
Toast.LENGTH_SHORT).show();
}
arg1.setAlpha((float) 0.4);
if((++i)== 4)
{
gridView.setAlpha((float)0.0);
p++;
final Integer q =
mImageIds[rgenerator.nextInt(mImageIds.length)];
ImageView imageView = (ImageView) iv;
imageView.setImageResource(q);
i=0;
gridView.invalidate();
}
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class ImageAdapter extends BaseAdapter {
// Keep all Images in array
// Constructor
public ImageAdapter(Context c){
mContext = c;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(tempArrayList[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
return imageView;
}
}
}``
Sunday, 15 September 2013
how to get width in pixels which has auto width?
how to get width in pixels which has auto width?
I have applied the following jquery and alerts the auto
var $divleft = $('#banner img').parent('div').css('left');
alert($divleft);
Is it possible to get the value of that div in pixels?
I have applied the following jquery and alerts the auto
var $divleft = $('#banner img').parent('div').css('left');
alert($divleft);
Is it possible to get the value of that div in pixels?
Php MySQL - Delete all rows by limit
Php MySQL - Delete all rows by limit
I want to delete all rows expect the 5 first rows.
/*example of the $count is equal to 5 */
$count=$xml->table->records->attributes();
This is my table:
xml_id
1
2
3
4
5
6
7
8
9
10
The result would be like this
xml_id
1
2
3
4
5
The above 5 will be deleted.
I want to delete all rows expect the 5 first rows.
/*example of the $count is equal to 5 */
$count=$xml->table->records->attributes();
This is my table:
xml_id
1
2
3
4
5
6
7
8
9
10
The result would be like this
xml_id
1
2
3
4
5
The above 5 will be deleted.
ArrayIndexOutOfBoundsException for array
ArrayIndexOutOfBoundsException for array
the statement:
public static void main(String[] args) {
int a[] = new int[ 3 ];
for( int j = 0; j <= 3; j++ )
System.out.println( a[j] );
}
gives me this:
0 0 0 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
3 at Untitled.main(Untitled.java:7)
Why is that so?
the statement:
public static void main(String[] args) {
int a[] = new int[ 3 ];
for( int j = 0; j <= 3; j++ )
System.out.println( a[j] );
}
gives me this:
0 0 0 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
3 at Untitled.main(Untitled.java:7)
Why is that so?
Problems configuring Lasso Lab on Windows
Problems configuring Lasso Lab on Windows
Trying to get LassoLab ( which is Eclipse based IDE for lasso ) to work on
Windows 7 Running into trouble launching a run configuration. Set it up
per video here http://www.youtube.com/watch?v=zMTQklE3Mu0 but it does not
work. I have Lasso 9 server with IIS installed and it runs fine Anyone is
doing Lasso development on Windows? LassoTalk list is very Mac centric and
I'm not getting any help there Thank you Andy
Trying to get LassoLab ( which is Eclipse based IDE for lasso ) to work on
Windows 7 Running into trouble launching a run configuration. Set it up
per video here http://www.youtube.com/watch?v=zMTQklE3Mu0 but it does not
work. I have Lasso 9 server with IIS installed and it runs fine Anyone is
doing Lasso development on Windows? LassoTalk list is very Mac centric and
I'm not getting any help there Thank you Andy
How can I pin down ASP MVC Razor profile using MiniPrfiler
How can I pin down ASP MVC Razor profile using MiniPrfiler
I have some views in my ASP MVC 4 web application that take several
seconds to render. I've install MiniProfiler to profile both the
controllers and Razor views. In one of my views I see the following
results:
duration (ms) from start (ms)
http://localhost:51405/Surveys/Details/201306... 4.8 +0.0
Controller: SurveysController.Details 2.2 +4.4
GetViewRows survey_with_tenant 6.1 +4.5
GetDocuments 5.7 +11.4
GetViewRows employees_by_surveyid 33.2 +17.2
GetDocuments 7.3 +51.4
Render : Details 1015.9 +59.4 <--- This is
the problem
Render partial: _LoginPartial 2.6 +450.2
The second to last line show that it took 1015 ms to render Details Razor
view. The partial used in it took 2.6 seconds, there are other partials
but they are even bellow 1 ms.
How can I further investigate what takes over 1 second to render?
I have some views in my ASP MVC 4 web application that take several
seconds to render. I've install MiniProfiler to profile both the
controllers and Razor views. In one of my views I see the following
results:
duration (ms) from start (ms)
http://localhost:51405/Surveys/Details/201306... 4.8 +0.0
Controller: SurveysController.Details 2.2 +4.4
GetViewRows survey_with_tenant 6.1 +4.5
GetDocuments 5.7 +11.4
GetViewRows employees_by_surveyid 33.2 +17.2
GetDocuments 7.3 +51.4
Render : Details 1015.9 +59.4 <--- This is
the problem
Render partial: _LoginPartial 2.6 +450.2
The second to last line show that it took 1015 ms to render Details Razor
view. The partial used in it took 2.6 seconds, there are other partials
but they are even bellow 1 ms.
How can I further investigate what takes over 1 second to render?
coonecting to mysql from perl uisng apache webserver?
coonecting to mysql from perl uisng apache webserver?
I am trying to test connectivity for the first time.like this
#!/usr/bin/perl -w
use DBI;
# DBD::ODBC
use CGI::Carp qw(fatalsToBrowser);
my $dsn = 'DBI:ODBC:Driver={SQL Server}';
#my $host = 'localhost';
my $host = 'mysql';
my $database = 'test';
my $user = 'root';
my $auth = 'mukesh';
# Connect via DBD::ODBC by specifying the DSN dynamically.
my $dbh = DBI->connect("$dsn;Server=$host;Database=$database",$user,$auth)
|| die "Database connection not made: $DBI::errstr";
but i am getting this error agian and again. Got error [Microsoft][ODBC
SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
(SQL-08001) [state was 08001 now 01000] [Microsoft][ODBC SQL Server
Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000) when connecting
to
Is there anything i need to configure in my pc before doing this.
I am trying to test connectivity for the first time.like this
#!/usr/bin/perl -w
use DBI;
# DBD::ODBC
use CGI::Carp qw(fatalsToBrowser);
my $dsn = 'DBI:ODBC:Driver={SQL Server}';
#my $host = 'localhost';
my $host = 'mysql';
my $database = 'test';
my $user = 'root';
my $auth = 'mukesh';
# Connect via DBD::ODBC by specifying the DSN dynamically.
my $dbh = DBI->connect("$dsn;Server=$host;Database=$database",$user,$auth)
|| die "Database connection not made: $DBI::errstr";
but i am getting this error agian and again. Got error [Microsoft][ODBC
SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
(SQL-08001) [state was 08001 now 01000] [Microsoft][ODBC SQL Server
Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000) when connecting
to
Is there anything i need to configure in my pc before doing this.
Adding multiple text fields with the same code
Adding multiple text fields with the same code
I want to be able to add between 1 and 20 text fields to my view with the
same code.
My idea is to use a for loop and every time add a text field so the first
time it loops it adds "textField1" and the second time it adds
"textField2" etc.
I'm not sure how I would go about coding this so I'm looking for your help.
I want to be able to add between 1 and 20 text fields to my view with the
same code.
My idea is to use a for loop and every time add a text field so the first
time it loops it adds "textField1" and the second time it adds
"textField2" etc.
I'm not sure how I would go about coding this so I'm looking for your help.
Saturday, 14 September 2013
What does image gradient mean in the following paper?
What does image gradient mean in the following paper?
I am working in digital image processing using java, recently I am
implementing a paper in java, One portion of this paper is this:
What I have understood from that is, G(i,j) would be intensity of image at
location (i, j) after applying soble operator on it, does it mean so or
anything else,
I have used the following code to compute wG,
public void weightedGCalc() {
BufferedImage sobelIm = this.getSobelImage();
int width = sobelIm.getWidth();
int height = sobelIm.getHeight();
weightedG = new double[width][height];
for (int row = 0; row < width; row++) {
for (int col = 0; col < height; col++) {
int imgPix = new Color(sobelIm.getRGB(row, col)).getRed();
float val = -(float) (Math.pow(imgPix, 2) / (2 *
Math.pow(SIGMA_G[5], 2)));
weightedG[row][col] = (float) Math.exp(val);
}
}
}
Here this.getSobelImage(); will give me sobel Image of a given image. I am
working with gray level images hence i am considering only one plane
(RED). Here SIGMA_G[5] contains value of sigmaG as suggested by Author.
I am working in digital image processing using java, recently I am
implementing a paper in java, One portion of this paper is this:
What I have understood from that is, G(i,j) would be intensity of image at
location (i, j) after applying soble operator on it, does it mean so or
anything else,
I have used the following code to compute wG,
public void weightedGCalc() {
BufferedImage sobelIm = this.getSobelImage();
int width = sobelIm.getWidth();
int height = sobelIm.getHeight();
weightedG = new double[width][height];
for (int row = 0; row < width; row++) {
for (int col = 0; col < height; col++) {
int imgPix = new Color(sobelIm.getRGB(row, col)).getRed();
float val = -(float) (Math.pow(imgPix, 2) / (2 *
Math.pow(SIGMA_G[5], 2)));
weightedG[row][col] = (float) Math.exp(val);
}
}
}
Here this.getSobelImage(); will give me sobel Image of a given image. I am
working with gray level images hence i am considering only one plane
(RED). Here SIGMA_G[5] contains value of sigmaG as suggested by Author.
JQuery append not working in IE 7
JQuery append not working in IE 7
Here is my code to insert table rows dynamically. It's not working with
ie7. But working with ie8,ie9 ,Chrome, Firefox.
for(var lvl=0;lvl<13;lvl++)
{
$("#check-form tbody").append( "<tr />");
for(var fchr=6;fchr<=36;fchr+=3)
{
if(fchr==6)
$("#check-form tbody").append( "<th scope=\"row\">"+hpa[lvl]+"
MB</th>");
$("#check-form tbody").append("<td><input type=\"checkbox\"
value="+('0'+fchr).slice(-2)+"_"+hpa[lvl]+"
id="+('0'+fchr).slice(-2)+"_"+hpa[lvl]+"
class=\"chkChart\"></input></td>");
}
}
Please help
Here is my code to insert table rows dynamically. It's not working with
ie7. But working with ie8,ie9 ,Chrome, Firefox.
for(var lvl=0;lvl<13;lvl++)
{
$("#check-form tbody").append( "<tr />");
for(var fchr=6;fchr<=36;fchr+=3)
{
if(fchr==6)
$("#check-form tbody").append( "<th scope=\"row\">"+hpa[lvl]+"
MB</th>");
$("#check-form tbody").append("<td><input type=\"checkbox\"
value="+('0'+fchr).slice(-2)+"_"+hpa[lvl]+"
id="+('0'+fchr).slice(-2)+"_"+hpa[lvl]+"
class=\"chkChart\"></input></td>");
}
}
Please help
How to get readable string from mysql with node.js?
How to get readable string from mysql with node.js?
When user register, i save its name in mysql (russian name in database
seems like - ÐÑминÑÐ). When I take data from database with PHP and
print out, it works good (show russian letters), but when user connect to
node.js server (using socket.io), make mysql query (using node-mysql
module) and receive data from query, then his name seems like -
ÐÑминÑÐ. How to get readable letters?
When user register, i save its name in mysql (russian name in database
seems like - ÐÑминÑÐ). When I take data from database with PHP and
print out, it works good (show russian letters), but when user connect to
node.js server (using socket.io), make mysql query (using node-mysql
module) and receive data from query, then his name seems like -
ÐÑминÑÐ. How to get readable letters?
X-axis labels are not displaying properly
X-axis labels are not displaying properly
I have created following dummy rCharts:
My_Data <- data.frame(Names = sapply(1:26, function(x)
return(paste(sample(letters, 26), collapse = ""))), Att1 = LETTERS, Number
= 1:26)
n1 <- nPlot(Number ~ Names, group = "Att1", data = My_Data, type =
"multiBarHorizontalChart")
n1$params$height = 5000
n1$params$width = 1000
n1
However when this plot is displayed in browser, the names in the x-axis
are not visible clearly. Those names are lengthy by how they have been
created in my original requirement. Can someone point me how to display
the full names?
Your help will be highly appreciated.
Thanks and regards,
I have created following dummy rCharts:
My_Data <- data.frame(Names = sapply(1:26, function(x)
return(paste(sample(letters, 26), collapse = ""))), Att1 = LETTERS, Number
= 1:26)
n1 <- nPlot(Number ~ Names, group = "Att1", data = My_Data, type =
"multiBarHorizontalChart")
n1$params$height = 5000
n1$params$width = 1000
n1
However when this plot is displayed in browser, the names in the x-axis
are not visible clearly. Those names are lengthy by how they have been
created in my original requirement. Can someone point me how to display
the full names?
Your help will be highly appreciated.
Thanks and regards,
Inserting XML in table
Inserting XML in table
I have an XML that looks like this:
<Weather Location="Tuzla, Bosnia and Herzegovina">
<Forecast>
<Description>sky is clear</Description>
<IconID>01d</IconID>
<Date>2013-09-14</Date>
<MinTemp>11</MinTemp>
<MaxTemp>21</MaxTemp>
<Pressure>994</Pressure>
<Humidity>39</Humidity>
<Wind>2</Wind>
</Forecast>
<Forecast>
<Description>scattered clouds</Description>
<IconID>03d</IconID>
<Date>2013-09-15</Date>
<MinTemp>9</MinTemp>
<MaxTemp>24</MaxTemp>
<Pressure>991</Pressure>
<Humidity>44</Humidity>
<Wind>1</Wind>
</Forecast>
<Forecast>
... //it has 10 Forecast parts
</Weather>
In my database I have table that has just two fields, ID and this XML. So,
when I insert new XML, i have to find out if there already exists XML with
this location, and where date from first Forecast parts are same. Is there
any way I can read only Date from first Forecast child of this root
element Weather? I know I have to go through my table and search every XML
file I have, and that's not problem, but what I need is just date from
only first forecast child.
Please help...
I have an XML that looks like this:
<Weather Location="Tuzla, Bosnia and Herzegovina">
<Forecast>
<Description>sky is clear</Description>
<IconID>01d</IconID>
<Date>2013-09-14</Date>
<MinTemp>11</MinTemp>
<MaxTemp>21</MaxTemp>
<Pressure>994</Pressure>
<Humidity>39</Humidity>
<Wind>2</Wind>
</Forecast>
<Forecast>
<Description>scattered clouds</Description>
<IconID>03d</IconID>
<Date>2013-09-15</Date>
<MinTemp>9</MinTemp>
<MaxTemp>24</MaxTemp>
<Pressure>991</Pressure>
<Humidity>44</Humidity>
<Wind>1</Wind>
</Forecast>
<Forecast>
... //it has 10 Forecast parts
</Weather>
In my database I have table that has just two fields, ID and this XML. So,
when I insert new XML, i have to find out if there already exists XML with
this location, and where date from first Forecast parts are same. Is there
any way I can read only Date from first Forecast child of this root
element Weather? I know I have to go through my table and search every XML
file I have, and that's not problem, but what I need is just date from
only first forecast child.
Please help...
Can anyone Help me solve this
Can anyone Help me solve this
Here Is my code and I am getting this error
root@ubuntu:~/public_html/todolist# ./manage.py sql todo SyntaxError:
invalid syntax (models.py, line 28)
from django.db import models
Create your models here.
class Todo(models.model):
name = models.CharField('Name',
max_lenght =200,
help_text = 'Enter the project name' )
def __unicode__(self):
return self.name
class Meta:
ordering = ('name',)
class TodoArticulo (models.Model):
fktodo = models.ForeignKey(Todo)
task = models.TextField('Task', help_text= ' Task Descripcion')
date = models.DateField()
def __unicode__(self):
return u'%s | %s' % (self.fktodo, self.task)
class Meta:
verbose_name= u 'Todo Task'
verbose_name_plural= 'Todo Tasks'
Here Is my code and I am getting this error
root@ubuntu:~/public_html/todolist# ./manage.py sql todo SyntaxError:
invalid syntax (models.py, line 28)
from django.db import models
Create your models here.
class Todo(models.model):
name = models.CharField('Name',
max_lenght =200,
help_text = 'Enter the project name' )
def __unicode__(self):
return self.name
class Meta:
ordering = ('name',)
class TodoArticulo (models.Model):
fktodo = models.ForeignKey(Todo)
task = models.TextField('Task', help_text= ' Task Descripcion')
date = models.DateField()
def __unicode__(self):
return u'%s | %s' % (self.fktodo, self.task)
class Meta:
verbose_name= u 'Todo Task'
verbose_name_plural= 'Todo Tasks'
Aggregate function calls cannot be nested
Aggregate function calls cannot be nested
I am consulting the docs from
http://www.querydsl.com/static/querydsl/3.2.1/reference/pdf/Querydsl_Reference.pdf
There I see the example
QDepartment department = QDepartment.department;
QDepartment d = new QDepartment("d");
query.from(department)
.where(department.employees.size().eq(
new JPASubQuery().from(d).unique(d.employees.size().max())
)).list(department);
I tried to execute the query using my tables with the code below:
QAdminEntity tableAdmin = QAdminEntity.adminEntity;
JPAQuery query = queryFrom( tableAdmin ).where(
tableAdmin.id_city.eq( idCity ).and(
tableAdmin.problems.size().eq(
subQueryFrom( tableAdmin ).unique(
tableAdmin.problems.size().min()
)
)
)
);
return query.singleResult( tableAdmin );
That code gives me an error, something like "Aggregate function calls
cannot be nested".
I am sorry for my lack of expertise on postgres and querydsl, but I
suppose this should be very straightforward.
The resulted query:
select
adminentit0_.id_admin as id1_3_,
adminentit0_.ds_email as ds2_3_,
adminentit0_.ds_name as ds3_3_,
adminentit0_.ds_password as ds4_3_,
adminentit0_.ds_username as ds5_3_,
adminentit0_.id_city as id6_3_,
adminentit0_.id_permission as id7_3_
from
m_admin adminentit0_
where
adminentit0_.id_city=?
and (
select
count(problems1_.id_admin)
from
m_problem problems1_
where
adminentit0_.id_admin=problems1_.id_admin
)=(
select
min(count(problems3_.id_admin))
from
m_admin adminentit2_,
m_problem problems3_
where
adminentit2_.id_admin=problems3_.id_admin
) limit ?
As you can see I want to list the admin that have less problems than
everyone else from the relation admin -> problems.
How can I make this work?
Adittional question:
Is it necessary to get another "QAdminEntity" field for the subQuery or
that "new QDepartment("d")"code is just for the example?
I am consulting the docs from
http://www.querydsl.com/static/querydsl/3.2.1/reference/pdf/Querydsl_Reference.pdf
There I see the example
QDepartment department = QDepartment.department;
QDepartment d = new QDepartment("d");
query.from(department)
.where(department.employees.size().eq(
new JPASubQuery().from(d).unique(d.employees.size().max())
)).list(department);
I tried to execute the query using my tables with the code below:
QAdminEntity tableAdmin = QAdminEntity.adminEntity;
JPAQuery query = queryFrom( tableAdmin ).where(
tableAdmin.id_city.eq( idCity ).and(
tableAdmin.problems.size().eq(
subQueryFrom( tableAdmin ).unique(
tableAdmin.problems.size().min()
)
)
)
);
return query.singleResult( tableAdmin );
That code gives me an error, something like "Aggregate function calls
cannot be nested".
I am sorry for my lack of expertise on postgres and querydsl, but I
suppose this should be very straightforward.
The resulted query:
select
adminentit0_.id_admin as id1_3_,
adminentit0_.ds_email as ds2_3_,
adminentit0_.ds_name as ds3_3_,
adminentit0_.ds_password as ds4_3_,
adminentit0_.ds_username as ds5_3_,
adminentit0_.id_city as id6_3_,
adminentit0_.id_permission as id7_3_
from
m_admin adminentit0_
where
adminentit0_.id_city=?
and (
select
count(problems1_.id_admin)
from
m_problem problems1_
where
adminentit0_.id_admin=problems1_.id_admin
)=(
select
min(count(problems3_.id_admin))
from
m_admin adminentit2_,
m_problem problems3_
where
adminentit2_.id_admin=problems3_.id_admin
) limit ?
As you can see I want to list the admin that have less problems than
everyone else from the relation admin -> problems.
How can I make this work?
Adittional question:
Is it necessary to get another "QAdminEntity" field for the subQuery or
that "new QDepartment("d")"code is just for the example?
Friday, 13 September 2013
Wants to get all rows from table. But returns searched rows only
Wants to get all rows from table. But returns searched rows only
This code is for sort the rows of JTable. I updates some values after sort
from the table. But I do some operation in this table, I got only searched
row count only. Not all rows.
public static void searchInTable(JTable table, JTextField text,
DefaultTableModel model, int column) {
TableRowSorter<DefaultTableModel> rowSorter = new
TableRowSorter<>(model);
table.setRowSorter(rowSorter);
String sortText = text.getText();
rowSorter.setRowFilter(RowFilter.regexFilter(sortText, column));
rowSorter.setSortKeys(null);
}
This code is for sort the rows of JTable. I updates some values after sort
from the table. But I do some operation in this table, I got only searched
row count only. Not all rows.
public static void searchInTable(JTable table, JTextField text,
DefaultTableModel model, int column) {
TableRowSorter<DefaultTableModel> rowSorter = new
TableRowSorter<>(model);
table.setRowSorter(rowSorter);
String sortText = text.getText();
rowSorter.setRowFilter(RowFilter.regexFilter(sortText, column));
rowSorter.setSortKeys(null);
}
Error while assigning values to a struct using pointers
Error while assigning values to a struct using pointers
I am new to C and have been trying to get this simple code run which makes
use of pointers to struct for calculating the average of grades entered.
After entering the maths grade, the program throws an error and stops.
What am I doing wrong. Its also my first post in here, so please bear with
me for any inconsistencies. Thanks!
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char *name;
int mathGrade,scienceGrade,historyGrade,englishGrade;
}reportCard;
void average(reportCard *rc)
{
int avg = (rc->mathGrade
+rc->scienceGrade+rc->historyGrade+rc->englishGrade)/4;
printf("The overall grade of %s is: %i ",rc->name, avg);
}
int main()
{
reportCard rc;
printf("Enter the Students Last name: ");
char studentName[20];
scanf("%s", studentName);
rc.name=studentName;
printf("Math Grade: \n");
scanf("%i", rc.mathGrade);
printf("Science Grade: \n");
scanf("%i", rc.scienceGrade);
printf("History Grade: \n");
scanf("%i", rc.historyGrade);
printf("English Grade: \n");
scanf("%i", rc.englishGrade);
average(&rc);
return 0;
}
I am new to C and have been trying to get this simple code run which makes
use of pointers to struct for calculating the average of grades entered.
After entering the maths grade, the program throws an error and stops.
What am I doing wrong. Its also my first post in here, so please bear with
me for any inconsistencies. Thanks!
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char *name;
int mathGrade,scienceGrade,historyGrade,englishGrade;
}reportCard;
void average(reportCard *rc)
{
int avg = (rc->mathGrade
+rc->scienceGrade+rc->historyGrade+rc->englishGrade)/4;
printf("The overall grade of %s is: %i ",rc->name, avg);
}
int main()
{
reportCard rc;
printf("Enter the Students Last name: ");
char studentName[20];
scanf("%s", studentName);
rc.name=studentName;
printf("Math Grade: \n");
scanf("%i", rc.mathGrade);
printf("Science Grade: \n");
scanf("%i", rc.scienceGrade);
printf("History Grade: \n");
scanf("%i", rc.historyGrade);
printf("English Grade: \n");
scanf("%i", rc.englishGrade);
average(&rc);
return 0;
}
Make not fit to screen on mobile? Its too tall and thin
Make not fit to screen on mobile? Its too tall and thin
I'm using an android device with the screen resolution of 720x1280. When I
load my page instead of making it scrollable it tries to fit the entire
thing. The page is 1250x1600 so i'm left with A LOT OF WHITESPACE and TINY
text.
How do I scale it to width and let the user scroll up/down. I'm using
bootstrap and jquery
I'm using an android device with the screen resolution of 720x1280. When I
load my page instead of making it scrollable it tries to fit the entire
thing. The page is 1250x1600 so i'm left with A LOT OF WHITESPACE and TINY
text.
How do I scale it to width and let the user scroll up/down. I'm using
bootstrap and jquery
how to set background xml file in drawable for a view?
how to set background xml file in drawable for a view?
how can I set an xml background file that placed in drawable for a view
without using @SuppressLint("NewApi") ?
for example I created a drawable xml file for my textview
when I call
TV.setBackground(getResources().getDrawable(R.drawable.tv_pic_back));
eclipse automatically add @SuppressLint("NewApi") at the first of my
function.
how can I use that without @SuppressLint("NewApi") ?
how can I set an xml background file that placed in drawable for a view
without using @SuppressLint("NewApi") ?
for example I created a drawable xml file for my textview
when I call
TV.setBackground(getResources().getDrawable(R.drawable.tv_pic_back));
eclipse automatically add @SuppressLint("NewApi") at the first of my
function.
how can I use that without @SuppressLint("NewApi") ?
Autoscrolling a datalist in an ASP page
Autoscrolling a datalist in an ASP page
I have an Aspx page with a panel and a datalist inside it connected to a
datasource. The datalist is showing news from an RSS feed and I have set
scroll bars to allow the users to read the hidden once. This is my code:
<asp:Panel ID="Panel1" runat="server" Height="270px" ScrollBars="Vertical"
Width="790px" BorderStyle="Outset" Direction="LeftToRight">
<asp:DataList ID="DataList3" runat="server" style="text-align:
left" DataSourceID="XmlDataSource1" CellPadding="4"
Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False"
ForeColor="#333333" HorizontalAlign="Justify">
<AlternatingItemStyle BackColor="White"
ForeColor="#284775" HorizontalAlign="Justify" />
<EditItemStyle Height="300px" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<ItemTemplate>
<%#XPath("title")%>
<br />
<%#XPath("pubDate")%>
<br />
<%#XPath("author")%>
<br />
<%#XPath("description")%>
</ItemTemplate>
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
</asp:DataList>
</asp:Panel>
I am trying to make the news scrolling continuously and if the user goes
over the control with the mouse, stop the autoscrolling and give control
to the mouse. How can I do something like that? Any reference or hint will
be appreciated.
I have an Aspx page with a panel and a datalist inside it connected to a
datasource. The datalist is showing news from an RSS feed and I have set
scroll bars to allow the users to read the hidden once. This is my code:
<asp:Panel ID="Panel1" runat="server" Height="270px" ScrollBars="Vertical"
Width="790px" BorderStyle="Outset" Direction="LeftToRight">
<asp:DataList ID="DataList3" runat="server" style="text-align:
left" DataSourceID="XmlDataSource1" CellPadding="4"
Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False"
ForeColor="#333333" HorizontalAlign="Justify">
<AlternatingItemStyle BackColor="White"
ForeColor="#284775" HorizontalAlign="Justify" />
<EditItemStyle Height="300px" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<ItemTemplate>
<%#XPath("title")%>
<br />
<%#XPath("pubDate")%>
<br />
<%#XPath("author")%>
<br />
<%#XPath("description")%>
</ItemTemplate>
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
</asp:DataList>
</asp:Panel>
I am trying to make the news scrolling continuously and if the user goes
over the control with the mouse, stop the autoscrolling and give control
to the mouse. How can I do something like that? Any reference or hint will
be appreciated.
delete items from listview in android
delete items from listview in android
I have listview which contains itemname and checkbox in front of item
name, and one delete button below layout, if my list contain 15 items then
only 10 items are visible, when i scoll down and check 15 item and then
press delete button, it will give the null pointer exception on check box,
following is my code to delete items from list view using check box.
deleteButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("Cursor length is "
+ cursor.getCount());
for (int i = 1; i <= cursor.getCount(); i++) {
listData.recomputeViewAttributes(view);
listData.getResources();
listData.smoothScrollToPosition(i);
view = listData.getChildAt(i);
box = (CheckBox) view.findViewById(i-1);
System.out.println("Count is "+i);
if (box.isChecked()) {
System.out.println("Box Checked");
/*cursor.moveToPosition(i);
int id = cursor.getInt(0);
System.out.println("Id is " + id);
controller.deleteBookmarkOnId(id);*/
}
}
dialog.dismiss();
}
});
I have listview which contains itemname and checkbox in front of item
name, and one delete button below layout, if my list contain 15 items then
only 10 items are visible, when i scoll down and check 15 item and then
press delete button, it will give the null pointer exception on check box,
following is my code to delete items from list view using check box.
deleteButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("Cursor length is "
+ cursor.getCount());
for (int i = 1; i <= cursor.getCount(); i++) {
listData.recomputeViewAttributes(view);
listData.getResources();
listData.smoothScrollToPosition(i);
view = listData.getChildAt(i);
box = (CheckBox) view.findViewById(i-1);
System.out.println("Count is "+i);
if (box.isChecked()) {
System.out.println("Box Checked");
/*cursor.moveToPosition(i);
int id = cursor.getInt(0);
System.out.println("Id is " + id);
controller.deleteBookmarkOnId(id);*/
}
}
dialog.dismiss();
}
});
Thursday, 12 September 2013
How to use .replace in python?
How to use .replace in python?
I want to replace a word in a string with another word. Ex.
replaceWord("cool","awesome","Stack overflow is cool.") Output would be:
"Stack overflow is awesome" I don't understand why my code isn't working.
def replaceWord(oldWord,newWord,aStr):
aStr.replace(oldWord,newWord)
return aStr
I want to replace a word in a string with another word. Ex.
replaceWord("cool","awesome","Stack overflow is cool.") Output would be:
"Stack overflow is awesome" I don't understand why my code isn't working.
def replaceWord(oldWord,newWord,aStr):
aStr.replace(oldWord,newWord)
return aStr
Toggling jquery submenu items
Toggling jquery submenu items
When I am trying to toggle the SubMenu item, the item toggles but the
first level menu is closed. The menu should not hide when the person
clicks on the sub menu item. for example if you click on SSNIT and goto
"core services" the sub menu appears but the first level menu item is
closed. Need some expertise for this fix? You can view the code on
JSFiddle here http://jsfiddle.net/3aRSr/.
HTML:
<div id="container">
<div style="display: inline-block">
<ul id="menu">
<li><a href="">Home</a></li>
<li>
<a href="#">SSNIT</a>
<ul>
<li>
<a href="">About SSNIT</a>
</li>
<li>
<a href="/Pages/new-ssnit.aspx">New SSNIT</a>
</li>
<li>
<a href="">Board of Trustees</a>
</li>
<li>
<a href="#">Core Services</a>
<ul>
<li><a href="/">Membership</a></li>
<li><a href="/">Investments</a></li>
<li><a href="/">Benefits</a></li>
<li><a href="/x">Students Loan</a></li>
</ul>
</li>
<li>
<a href="/">Executive Committee</a>
</li>
<li>
<a href="">Mission and Vision</a>
</li>
</ul>
</li>
<li><a href="">Statistics</a></li>
<li><a href="">News</a></li>
<li><a href="">Resources</a></li>
<li>
<a href="#">Self Services</a>
<ul>
<li>
<a href="#">Benefit Application</a>
</li>
<li>
<a href="#">Employer Enrolment</a>
</li>
<li>
<a href="#">Member Enrolment</a>
</li>
</ul>
</li>
<li><a href="">FAQs</a></li>
<li>
<a href="#">Contact Us</a>
<ul>
<li>
<a href="/">Contact Information</a>
</li>
<li>
<a href="/">Customer Service Locations</a>
</li>
<li>
<a href="/">Telephone Directory</a>
</li>
<li>
<a href="/">SSNIT Locations Map</a>
</li>
</ul>
</li>
</ul>
</div>
CSS:
#menu, #menu2, #container {
width: 100%;
margin: 0;
padding: 1px 0 0 0;
list-style: none;
background: #DCDCDC;
}
#menu li, #menu2 li {
float: left;
padding: 0 0 0 0;
position: relative;
line-height: 0;
}
#menu a, #menu2 a {
float: left;
height: 25px;
padding-top: 0;
padding-bottom: 0;
padding-left: 10px;
padding-right: 10px;
color: #403E3F;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
}
#menu li:hover > a, #menu2 li:hover > a {
color: #fafafa;
}
#menu li a:hover, #menu2 li a:hover /* IE6 */ {
color: #fafafa;
}
#menu li:hover > ul, #menu2 li:hover > ul {
/*display: block;*/
}
/* Sub-menu */
#menu ul, #menu2 ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
top: 40px; /* louis: 50px */
left: 0;
z-index: 99999;
background: #DCDCDC;
}
#menu ul ul, #menu2 ul ul {
top: 0px;
left: 195px; /* louis: 160px */
}
#menu ul li, #menu2 ul li {
float: none;
margin: 0;
padding: 0;
display: block;
-moz-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
-webkit-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
}
#menu ul li:last-child, #menu2 ul li:last-child {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#menu ul a, #menu2 ul a {
padding: 10px;
height: 10px;
width: 165px;
height: auto;
line-height: 1;
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a, #menu2 ul a /* IE6 */ {
height: 10px;
}
*:first-child + html #menu ul a, *:first-child + html #menu2
ul a /* IE7 */ {
height: 10px;
}
#menu ul a:hover, #menu2 ul a:hover {
background: #0186ba;
}
#menu ul li:first-child > a, #menu2 ul li:first-child > a {
}
#menu ul li:first-child > a:after, #menu2 ul
li:first-child > a:after {
content: '';
position: absolute;
left: 30px;
top: -10px;
width: 0;
height: 0;
border-left: 12px solid transparent;
border-right: 12px solid transparent;
border-bottom: 16px solid #DCDCDC;
}
#menu ul ul li:first-child a:after, #menu2 ul ul
li:first-child a:after {
left: -10px;
top: 5px;
width: 0;
height: 0;
border-left: 0;
border-bottom: 12px solid transparent;
border-top: 12px solid transparent;
border-right: 16px solid #DCDCDC;
}
#menu ul li:first-child a:hover:after, #menu2 ul
li:first-child a:hover:after {
border-bottom-color: #0186ba;
}
#menu ul ul li:first-child a:hover:after, #menu2 ul ul
li:first-child a:hover:after {
border-right-color: #0186ba;
border-bottom-color: transparent;
}
#menu ul li:last-child > a, #menu2 ul li:last-child > a {
}
Clear floated elements #menu:after, #menu2:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html #menu, * html #menu2 {
zoom: 1;
}
IE6 *:first-child + html #menu, *:first-child + html #menu2 {
zoom: 1;
}
JavaScript:
$(document).ready(function () {
$("#menu ul li, #menu > li ul li").click(function () {
//mouse click toggle menu items
$('>ul').toggle(
// mouseover
function () {
$(this).find('>ul').fadeIn('slow');
});
});
});
When I am trying to toggle the SubMenu item, the item toggles but the
first level menu is closed. The menu should not hide when the person
clicks on the sub menu item. for example if you click on SSNIT and goto
"core services" the sub menu appears but the first level menu item is
closed. Need some expertise for this fix? You can view the code on
JSFiddle here http://jsfiddle.net/3aRSr/.
HTML:
<div id="container">
<div style="display: inline-block">
<ul id="menu">
<li><a href="">Home</a></li>
<li>
<a href="#">SSNIT</a>
<ul>
<li>
<a href="">About SSNIT</a>
</li>
<li>
<a href="/Pages/new-ssnit.aspx">New SSNIT</a>
</li>
<li>
<a href="">Board of Trustees</a>
</li>
<li>
<a href="#">Core Services</a>
<ul>
<li><a href="/">Membership</a></li>
<li><a href="/">Investments</a></li>
<li><a href="/">Benefits</a></li>
<li><a href="/x">Students Loan</a></li>
</ul>
</li>
<li>
<a href="/">Executive Committee</a>
</li>
<li>
<a href="">Mission and Vision</a>
</li>
</ul>
</li>
<li><a href="">Statistics</a></li>
<li><a href="">News</a></li>
<li><a href="">Resources</a></li>
<li>
<a href="#">Self Services</a>
<ul>
<li>
<a href="#">Benefit Application</a>
</li>
<li>
<a href="#">Employer Enrolment</a>
</li>
<li>
<a href="#">Member Enrolment</a>
</li>
</ul>
</li>
<li><a href="">FAQs</a></li>
<li>
<a href="#">Contact Us</a>
<ul>
<li>
<a href="/">Contact Information</a>
</li>
<li>
<a href="/">Customer Service Locations</a>
</li>
<li>
<a href="/">Telephone Directory</a>
</li>
<li>
<a href="/">SSNIT Locations Map</a>
</li>
</ul>
</li>
</ul>
</div>
CSS:
#menu, #menu2, #container {
width: 100%;
margin: 0;
padding: 1px 0 0 0;
list-style: none;
background: #DCDCDC;
}
#menu li, #menu2 li {
float: left;
padding: 0 0 0 0;
position: relative;
line-height: 0;
}
#menu a, #menu2 a {
float: left;
height: 25px;
padding-top: 0;
padding-bottom: 0;
padding-left: 10px;
padding-right: 10px;
color: #403E3F;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
}
#menu li:hover > a, #menu2 li:hover > a {
color: #fafafa;
}
#menu li a:hover, #menu2 li a:hover /* IE6 */ {
color: #fafafa;
}
#menu li:hover > ul, #menu2 li:hover > ul {
/*display: block;*/
}
/* Sub-menu */
#menu ul, #menu2 ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
top: 40px; /* louis: 50px */
left: 0;
z-index: 99999;
background: #DCDCDC;
}
#menu ul ul, #menu2 ul ul {
top: 0px;
left: 195px; /* louis: 160px */
}
#menu ul li, #menu2 ul li {
float: none;
margin: 0;
padding: 0;
display: block;
-moz-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
-webkit-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
}
#menu ul li:last-child, #menu2 ul li:last-child {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#menu ul a, #menu2 ul a {
padding: 10px;
height: 10px;
width: 165px;
height: auto;
line-height: 1;
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a, #menu2 ul a /* IE6 */ {
height: 10px;
}
*:first-child + html #menu ul a, *:first-child + html #menu2
ul a /* IE7 */ {
height: 10px;
}
#menu ul a:hover, #menu2 ul a:hover {
background: #0186ba;
}
#menu ul li:first-child > a, #menu2 ul li:first-child > a {
}
#menu ul li:first-child > a:after, #menu2 ul
li:first-child > a:after {
content: '';
position: absolute;
left: 30px;
top: -10px;
width: 0;
height: 0;
border-left: 12px solid transparent;
border-right: 12px solid transparent;
border-bottom: 16px solid #DCDCDC;
}
#menu ul ul li:first-child a:after, #menu2 ul ul
li:first-child a:after {
left: -10px;
top: 5px;
width: 0;
height: 0;
border-left: 0;
border-bottom: 12px solid transparent;
border-top: 12px solid transparent;
border-right: 16px solid #DCDCDC;
}
#menu ul li:first-child a:hover:after, #menu2 ul
li:first-child a:hover:after {
border-bottom-color: #0186ba;
}
#menu ul ul li:first-child a:hover:after, #menu2 ul ul
li:first-child a:hover:after {
border-right-color: #0186ba;
border-bottom-color: transparent;
}
#menu ul li:last-child > a, #menu2 ul li:last-child > a {
}
Clear floated elements #menu:after, #menu2:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html #menu, * html #menu2 {
zoom: 1;
}
IE6 *:first-child + html #menu, *:first-child + html #menu2 {
zoom: 1;
}
JavaScript:
$(document).ready(function () {
$("#menu ul li, #menu > li ul li").click(function () {
//mouse click toggle menu items
$('>ul').toggle(
// mouseover
function () {
$(this).find('>ul').fadeIn('slow');
});
});
});
Subscribe to:
Posts (Atom)