LWP::UserAgent and HTTP::Request for a POST request
In a certain script I tried to write this:
my $ua = LWP::UserAgent->new;
my $res = $ua->post($url, Content => $data);
and got "400 Bad Request". After some reading I tried this:
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new( 'POST', $url );
$req->content( $data );
my $res = $ua->request( $req );
and it worked, but I thought these two should do the same. What am I
missing here? Am I misunderstanding something in the documentation of
HTTP::Request and LWP::UserAgent?
Is there a way to ask LWP::UserAgent to print what it is doing?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Complex Regex composition - Regex that match "if"
Complex Regex composition - Regex that match "if"
I'm making a Regex to match hashtags to my project. I want that regex
match hashtags that are separeted by one single space, don't have another
hashtag inside this content and just match a space in the string if this
is followed by any word (except other blank space or #).
I'm really curious to know if I can do something like "if" in regular
expressions and I hope you can help me with this.
So, in:
"#hashtag?!-=_" "#hashhash#" "#hash tag" "#hash tag" "#hash
#ahuhuhhuasd" "#hash "
The regex must match the following sentences:
"#hashtag?!-=_" "#hashhash" "#hash tag" "#hash" "#hash #ahuhuhhuasd" "#hash"
(all hashtag) (one) (another h.)
Actually, this is my code:
#{1,1}\S+\s{0,1}
You can test here this code, but it matches things that isn't desired:
"#ahusdhuas?!__??###hud #ahusdhuads "
The blank space in the end of the string, the 3 '#' inside the string.
none of the following content is desired in this string, just
"#ahusdhuas?!__??"
Glad if you can help me!
I'm making a Regex to match hashtags to my project. I want that regex
match hashtags that are separeted by one single space, don't have another
hashtag inside this content and just match a space in the string if this
is followed by any word (except other blank space or #).
I'm really curious to know if I can do something like "if" in regular
expressions and I hope you can help me with this.
So, in:
"#hashtag?!-=_" "#hashhash#" "#hash tag" "#hash tag" "#hash
#ahuhuhhuasd" "#hash "
The regex must match the following sentences:
"#hashtag?!-=_" "#hashhash" "#hash tag" "#hash" "#hash #ahuhuhhuasd" "#hash"
(all hashtag) (one) (another h.)
Actually, this is my code:
#{1,1}\S+\s{0,1}
You can test here this code, but it matches things that isn't desired:
"#ahusdhuas?!__??###hud #ahusdhuads "
The blank space in the end of the string, the 3 '#' inside the string.
none of the following content is desired in this string, just
"#ahusdhuas?!__??"
Glad if you can help me!
Problems with geotools library to create a .jar?
Problems with geotools library to create a .jar?
I have a java project and it works in eclipse then I create a .jar for
this project and when a try to execute the jar the following errors
appears:
If I create the .jar with eclipse: Exception in thread "main"
java.lang.NoClassDefFoundError: org/geotools/data/FeatureSource
If I create the .jar with mvn: Error: no se ha encontrato o cargado la
clase principal client.Client
Thanks
I have a java project and it works in eclipse then I create a .jar for
this project and when a try to execute the jar the following errors
appears:
If I create the .jar with eclipse: Exception in thread "main"
java.lang.NoClassDefFoundError: org/geotools/data/FeatureSource
If I create the .jar with mvn: Error: no se ha encontrato o cargado la
clase principal client.Client
Thanks
comparing pointer to a negative value
comparing pointer to a negative value
Can i typecast a pointer to a structure to a signed value to return a
different types of errors. Does the C standard allow this or is an
undefined behaviour.
typedef enum lError
{
l_OK = 0,
l_ERROR = -1,
l_ABORT = -2,
l_HALT = -3
}L_STATUS;
typedef struct dataCards
{
int card1;
int card2;
char flag;
}DATACARD;
DATACARD dataCardG;
DATACARD *getCard(int i)
{
if(i == 1)
return &dataCardG;
else if (i == 2)
return (DATACARD *)l_ERROR;
else if (i==3)
return (DATACARD *)l_ABORT;
else
return (DATACARD *)l_HALT;
}
int main ()
{
DATACARD *ptr = NULL;
ptr = getCard(3);
if(ptr < (DATACARD *) 1) /* Is this allowed or undefined behaviour */
printf("Card failed\n");
}
How can i make this condition work?
Can i typecast a pointer to a structure to a signed value to return a
different types of errors. Does the C standard allow this or is an
undefined behaviour.
typedef enum lError
{
l_OK = 0,
l_ERROR = -1,
l_ABORT = -2,
l_HALT = -3
}L_STATUS;
typedef struct dataCards
{
int card1;
int card2;
char flag;
}DATACARD;
DATACARD dataCardG;
DATACARD *getCard(int i)
{
if(i == 1)
return &dataCardG;
else if (i == 2)
return (DATACARD *)l_ERROR;
else if (i==3)
return (DATACARD *)l_ABORT;
else
return (DATACARD *)l_HALT;
}
int main ()
{
DATACARD *ptr = NULL;
ptr = getCard(3);
if(ptr < (DATACARD *) 1) /* Is this allowed or undefined behaviour */
printf("Card failed\n");
}
How can i make this condition work?
Getting the JAXB exception like "Two classes have the same XML type name..."
Getting the JAXB exception like "Two classes have the same XML type name..."
Getting the JAXB exception like "Two classes have the same XML type name...",
Here is the exception details:
Exception in thread "main"
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts
of IllegalAnnotationExceptions Two classes have the same XML type name
"city". Use @XmlType.name and @XmlType.namespace to assign different names
to them. this problem is related to the following location: at
com.model.City at public com.model.City com.model.Address.getCurrentCity()
at com.model.Address this problem is related to the following location: at
com.common.City at public com.common.City
com.model.Address.getPreviousCity() at com.model.Address
at
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown
Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown
Source) at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown
Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
javax.xml.bind.ContextFinder.newInstance(Unknown Source) at
javax.xml.bind.ContextFinder.find(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
com.PojoToXSD.main(PojoToXSD.java:17)
I took the example like:
package com.model; ---->this package contains 'Address' class and 'City'
class
public class Address {
private String areaName;
private City currentCity;
private com.common.City previousCity;
}
package com.model;
public class City {
private String cityName;
}
Another city class in "com.common" package.
package com.common;
public class City {
private String pinCode;
}
We need to create XSDs and needs to do the Marshalling and unmarshalling
with the existing code in our project(like as above example code), code
does not have any annotations like "@XmlRootElement/@XmlType" and we can
not able to change the source code.
I would like to know is there any solution to fix the above issue or any
other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
It would be great if i can get the solution from any one....May thanks in
advance.
Thanks,
Satya.
Getting the JAXB exception like "Two classes have the same XML type name...",
Here is the exception details:
Exception in thread "main"
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts
of IllegalAnnotationExceptions Two classes have the same XML type name
"city". Use @XmlType.name and @XmlType.namespace to assign different names
to them. this problem is related to the following location: at
com.model.City at public com.model.City com.model.Address.getCurrentCity()
at com.model.Address this problem is related to the following location: at
com.common.City at public com.common.City
com.model.Address.getPreviousCity() at com.model.Address
at
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown
Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown
Source) at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown
Source) at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown
Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
javax.xml.bind.ContextFinder.newInstance(Unknown Source) at
javax.xml.bind.ContextFinder.find(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
javax.xml.bind.JAXBContext.newInstance(Unknown Source) at
com.PojoToXSD.main(PojoToXSD.java:17)
I took the example like:
package com.model; ---->this package contains 'Address' class and 'City'
class
public class Address {
private String areaName;
private City currentCity;
private com.common.City previousCity;
}
package com.model;
public class City {
private String cityName;
}
Another city class in "com.common" package.
package com.common;
public class City {
private String pinCode;
}
We need to create XSDs and needs to do the Marshalling and unmarshalling
with the existing code in our project(like as above example code), code
does not have any annotations like "@XmlRootElement/@XmlType" and we can
not able to change the source code.
I would like to know is there any solution to fix the above issue or any
other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
It would be great if i can get the solution from any one....May thanks in
advance.
Thanks,
Satya.
Tuesday, 1 October 2013
Multiple and dynamic databases in doctrine 2
Multiple and dynamic databases in doctrine 2
I checked already multiple answers on stackoverflow but couldnt find a
sufficient answer for that problem.
Imagine I have a MAIN database and multiple SLAVE databases. Based on some
information in the MAIN database I will then know which SLAVE database I
will connect to and which table I will use for my model.
As an example:
A Person entity can be connected to a database1234 database using the
table person_india or to database7834 using a table person_uk etc. Which
one I will connect to is decide on runtime and cant be configured before.
What I found so far:
I can directly bind a model to a database.table via
@Entity @Table(name="databaseName.tablename")
So Im able to join over databases. So basically Im ignoring the dbname in
the connection params for the entityManager.
Question:
How to dynamically set the information(database,table) for an entity on
the fly?
Will this affect caching?
If this is not possible in a good manner. Is there any other orm which
will provide me that kind of functionality.
Thanks in advance
I checked already multiple answers on stackoverflow but couldnt find a
sufficient answer for that problem.
Imagine I have a MAIN database and multiple SLAVE databases. Based on some
information in the MAIN database I will then know which SLAVE database I
will connect to and which table I will use for my model.
As an example:
A Person entity can be connected to a database1234 database using the
table person_india or to database7834 using a table person_uk etc. Which
one I will connect to is decide on runtime and cant be configured before.
What I found so far:
I can directly bind a model to a database.table via
@Entity @Table(name="databaseName.tablename")
So Im able to join over databases. So basically Im ignoring the dbname in
the connection params for the entityManager.
Question:
How to dynamically set the information(database,table) for an entity on
the fly?
Will this affect caching?
If this is not possible in a good manner. Is there any other orm which
will provide me that kind of functionality.
Thanks in advance
How to trigger two function on form submit?
How to trigger two function on form submit?
I have a form when the form is submitted i'll call one javascript function
and action it to to form handler.
<form action="subscribe.php" onsubmit="return form_check(this)"
method="post">
<input type="text" value="">
<input type="submit" value="click">
</form>
Everything Works fine, Now i want to send the same form fields to another
javascript function so i tried like this on submit code
<form action="subscribe.php"
onsubmit="return (form_check(this) & another_script(this))" method="post">
Added & in onsubmit but the function is not triggering when the button is
clicked. I think this is due to the action="subscribe.php" in the form.
I want to send the form value to another javascript function also. how can
i achieve this?
I have a form when the form is submitted i'll call one javascript function
and action it to to form handler.
<form action="subscribe.php" onsubmit="return form_check(this)"
method="post">
<input type="text" value="">
<input type="submit" value="click">
</form>
Everything Works fine, Now i want to send the same form fields to another
javascript function so i tried like this on submit code
<form action="subscribe.php"
onsubmit="return (form_check(this) & another_script(this))" method="post">
Added & in onsubmit but the function is not triggering when the button is
clicked. I think this is due to the action="subscribe.php" in the form.
I want to send the form value to another javascript function also. how can
i achieve this?
What's a neutral word for "father" and "mother"? english.stackexchange.com
What's a neutral word for "father" and "mother"? – english.stackexchange.com
Is there a neutral word to refer to "father" and "mother" without the
family connotations? For example, there was a guy who refer to his parents
using the terms "sperm and egg bank": They were my …
Is there a neutral word to refer to "father" and "mother" without the
family connotations? For example, there was a guy who refer to his parents
using the terms "sperm and egg bank": They were my …
Postix dosen't forward to Gmail Yahoo Hotmail
Postix dosen't forward to Gmail Yahoo Hotmail
I have a problem with my Postfix 2.8.4 (Cent OS 6 with Plesk 11.0)
If i sent an email to one of these providers, it will be delivered ok.
If I setup my email to forward all emails to one of these providers:
a. if i sent from an email from the same server, it will be delivered ok
b. If I sent from an email not hosted on the server, the mail will be
stuck in the queue forever.
Below is my main.cf
#
#soft_bounce = no
# LOCAL PATHNAME INFORMATION
#
queue_directory = /var/spool/postfix
# The command_directory parameter specifies the location of all
# postXXX commands.
#
command_directory = /usr/sbin
# The daemon_directory parameter specifies the location of all Postfix
# daemon programs (i.e. programs listed in the master.cf file). This
# directory must be owned by root.
#
daemon_directory = /usr/libexec/postfix
# The data_directory parameter specifies the location of Postfix-writable
# data files (caches, random numbers). This directory must be owned
# by the mail_owner account (see below).
#
data_directory = /var/lib/postfix
# QUEUE AND PROCESS OWNERSHIP
#
#
mail_owner = postfix
#
#default_privs = nobody
# INTERNET HOST AND DOMAIN NAMES
#
#
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld
#
#mydomain = domain.tld
# SENDING MAIL
#
#myorigin = $myhostname
#myorigin = $mydomain
# RECEIVING MAIL
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = all
# Enable IPv4, and IPv6 if supported
inet_protocols = all
#
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4
#
mydestination = localhost.$mydomain, localhost, localhost.localdomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
#
#local_recipient_maps = unix:passwd.byname $alias_maps
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
#local_recipient_maps =
#
unknown_local_recipient_reject_code = 550
# TRUST AND RELAY CONTROL
#
#mynetworks_style = class
#mynetworks_style = subnet
mynetworks_style = host
#
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
#
#relay_domains = $mydestination
# INTERNET OR INTRANET
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
# REJECTING UNKNOWN RELAY USERS
#
#
#relay_recipient_maps = hash:/etc/postfix/relay_recipients
# INPUT RATE CONTROL
#
#
#in_flow_delay = 1s
# ADDRESS REWRITING
#
# The ADDRESS_REWRITING_README document gives information about
# address masquerading or other forms of address rewriting including
# username->Firstname.Lastname mapping.
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
# "USER HAS MOVED" BOUNCE MESSAGES
#
# See the discussion in the ADDRESS_REWRITING_README document.
# TRANSPORT MAP
#
# See the discussion in the ADDRESS_REWRITING_README document.
# ALIAS DATABASE
#
#
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
# The alias_database parameter specifies the alias database(s) that
# are built with "newaliases" or "sendmail -bi". This is a separate
# configuration parameter, because alias_maps (see above) may specify
# tables that are not necessarily all under control by Postfix.
#
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
# ADDRESS EXTENSIONS (e.g., user+foo)
#
#
#recipient_delimiter = +
# DELIVERY TO MAILBOX
#
#
#home_mailbox = Mailbox
#home_mailbox = Maildir/
# The mail_spool_directory parameter specifies the directory where
# UNIX-style mailboxes are kept. The default setting depends on the
# system type.
#
#mail_spool_directory = /var/mail
#mail_spool_directory = /var/spool/mail
# The mailbox_command parameter specifies the optional external
# command to use instead of mailbox delivery. The command is run as
# the recipient with proper HOME, SHELL and LOGNAME environment settings.
# Exception: delivery for root is done as $default_user.
#
#
#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"
#
#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#
# To use the old cyrus deliver program you have to set:
#mailbox_transport = cyrus
#
#fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#fallback_transport =
#luser_relay = $user@other.host
#luser_relay = $local@other.host
#luser_relay = admin+$local
# JUNK MAIL CONTROLS
#
#
#header_checks = regexp:/etc/postfix/header_checks
# FAST ETRN SERVICE
#
#
#fast_flush_domains = $relay_domains
# SHOW SOFTWARE VERSION OR NOT
#
#
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
# PARALLEL DELIVERY TO THE SAME DESTINATION
#
#local_destination_concurrency_limit = 2
#default_destination_concurrency_limit = 20
# DEBUGGING CONTROL
#
#
debug_peer_level = 2
#
#debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain
#
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
#
# debugger_command =
# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
# -dmS $process_name gdb $daemon_directory/$process_name
# $process_id & sleep 1
# INSTALL-TIME CONFIGURATION INFORMATION
#
# The following parameters are used when installing a new Postfix version.
#
# sendmail_path: The full pathname of the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
#
sendmail_path = /usr/sbin/sendmail.postfix
# newaliases_path: The full pathname of the Postfix newaliases command.
# This is the Sendmail-compatible command to build alias databases.
#
newaliases_path = /usr/bin/newaliases.postfix
# mailq_path: The full pathname of the Postfix mailq command. This
# is the Sendmail-compatible mail queue listing command.
#
mailq_path = /usr/bin/mailq.postfix
# setgid_group: The group for mail submission and queue management
# commands. This must be a group name with a numerical group ID that
# is not shared with other accounts, not even with the Postfix account.
#
setgid_group = postdrop
# html_directory: The location of the Postfix HTML documentation.
#
html_directory = no
# manpage_directory: The location of the Postfix on-line manual pages.
#
manpage_directory = /usr/share/man
# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory = /usr/share/doc/postfix-2.8.4/samples
# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.8.4/README_FILES
virtual_mailbox_domains = $virtual_mailbox_maps,
hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox
transport_maps = hash:/var/spool/postfix/plesk/transport
smtpd_tls_cert_file = /etc/postfix/postfix_default.pem
smtpd_tls_key_file = $smtpd_tls_cert_file
smtpd_tls_security_level = may
smtpd_use_tls = yes
smtp_tls_security_level = may
smtp_use_tls = no
smtpd_timeout = 3600s
smtpd_proxy_timeout = 3600s
disable_vrfy_command = yes
mynetworks = 127.0.0.0/8, [::1]/128, xxx.xxx.xxx.xxx/32
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,
reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, permit
smtpd_sender_restrictions = permit_mynetworks,
reject_unknown_sender_domain, reject_unknown_address,
reject_unlisted_sender, reject_non_fqdn_sender,
reject_unknown_sender_domain, permit
# smtpd_client_restrictions = permit_mynetworks, reject_rbl_client
sbl.spamhaus.org
smtp_send_xforward_command = yes
smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated, reject_unauth_destination, permit
# smtpd_recipient_restrictions = reject_unauth_pipelining,
reject_non_fqdn_recipient, reject_unknown_recipient_domain,
permit_mynetworks, reject_unauth_destination, check_sender_access
hash:/etc/postfix/sender_access, reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net, check_policy_service
unix:postgrey/socket, permit
virtual_mailbox_base = /var/qmail/mailnames
virtual_uid_maps = static:110
virtual_gid_maps = static:30
smtpd_milters = inet:localhost:12768
non_smtpd_milters = inet:localhost:12768
sender_dependent_default_transport_maps =
hash:/var/spool/postfix/plesk/sdd_transport_maps
virtual_transport = plesk_virtual
plesk_virtual_destination_recipient_limit = 1
mailman_destination_recipient_limit = 1
myhostname = mail.myinternet.gr
milter_connect_macros = j {daemon_name} v
milter_data_macros = i
milter_end_of_data_macros = i
milter_end_of_header_macros = i
milter_helo_macros = {tls_version} {cipher} {cipher_bits} {cert_subject}
{cert_issuer}
milter_macro_daemon_name = $myhostname
milter_macro_v = $mail_name $mail_version
milter_mail_macros = i {auth_type} {auth_authen} {auth_author} {mail_addr}
milter_rcpt_macros = i {rcpt_addr}
message_size_limit = 40960000
Thank you for your time
I have a problem with my Postfix 2.8.4 (Cent OS 6 with Plesk 11.0)
If i sent an email to one of these providers, it will be delivered ok.
If I setup my email to forward all emails to one of these providers:
a. if i sent from an email from the same server, it will be delivered ok
b. If I sent from an email not hosted on the server, the mail will be
stuck in the queue forever.
Below is my main.cf
#
#soft_bounce = no
# LOCAL PATHNAME INFORMATION
#
queue_directory = /var/spool/postfix
# The command_directory parameter specifies the location of all
# postXXX commands.
#
command_directory = /usr/sbin
# The daemon_directory parameter specifies the location of all Postfix
# daemon programs (i.e. programs listed in the master.cf file). This
# directory must be owned by root.
#
daemon_directory = /usr/libexec/postfix
# The data_directory parameter specifies the location of Postfix-writable
# data files (caches, random numbers). This directory must be owned
# by the mail_owner account (see below).
#
data_directory = /var/lib/postfix
# QUEUE AND PROCESS OWNERSHIP
#
#
mail_owner = postfix
#
#default_privs = nobody
# INTERNET HOST AND DOMAIN NAMES
#
#
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld
#
#mydomain = domain.tld
# SENDING MAIL
#
#myorigin = $myhostname
#myorigin = $mydomain
# RECEIVING MAIL
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = all
# Enable IPv4, and IPv6 if supported
inet_protocols = all
#
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4
#
mydestination = localhost.$mydomain, localhost, localhost.localdomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
#
#local_recipient_maps = unix:passwd.byname $alias_maps
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
#local_recipient_maps =
#
unknown_local_recipient_reject_code = 550
# TRUST AND RELAY CONTROL
#
#mynetworks_style = class
#mynetworks_style = subnet
mynetworks_style = host
#
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
#
#relay_domains = $mydestination
# INTERNET OR INTRANET
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
# REJECTING UNKNOWN RELAY USERS
#
#
#relay_recipient_maps = hash:/etc/postfix/relay_recipients
# INPUT RATE CONTROL
#
#
#in_flow_delay = 1s
# ADDRESS REWRITING
#
# The ADDRESS_REWRITING_README document gives information about
# address masquerading or other forms of address rewriting including
# username->Firstname.Lastname mapping.
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
# "USER HAS MOVED" BOUNCE MESSAGES
#
# See the discussion in the ADDRESS_REWRITING_README document.
# TRANSPORT MAP
#
# See the discussion in the ADDRESS_REWRITING_README document.
# ALIAS DATABASE
#
#
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
# The alias_database parameter specifies the alias database(s) that
# are built with "newaliases" or "sendmail -bi". This is a separate
# configuration parameter, because alias_maps (see above) may specify
# tables that are not necessarily all under control by Postfix.
#
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
# ADDRESS EXTENSIONS (e.g., user+foo)
#
#
#recipient_delimiter = +
# DELIVERY TO MAILBOX
#
#
#home_mailbox = Mailbox
#home_mailbox = Maildir/
# The mail_spool_directory parameter specifies the directory where
# UNIX-style mailboxes are kept. The default setting depends on the
# system type.
#
#mail_spool_directory = /var/mail
#mail_spool_directory = /var/spool/mail
# The mailbox_command parameter specifies the optional external
# command to use instead of mailbox delivery. The command is run as
# the recipient with proper HOME, SHELL and LOGNAME environment settings.
# Exception: delivery for root is done as $default_user.
#
#
#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"
#
#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#
# To use the old cyrus deliver program you have to set:
#mailbox_transport = cyrus
#
#fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#fallback_transport =
#luser_relay = $user@other.host
#luser_relay = $local@other.host
#luser_relay = admin+$local
# JUNK MAIL CONTROLS
#
#
#header_checks = regexp:/etc/postfix/header_checks
# FAST ETRN SERVICE
#
#
#fast_flush_domains = $relay_domains
# SHOW SOFTWARE VERSION OR NOT
#
#
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
# PARALLEL DELIVERY TO THE SAME DESTINATION
#
#local_destination_concurrency_limit = 2
#default_destination_concurrency_limit = 20
# DEBUGGING CONTROL
#
#
debug_peer_level = 2
#
#debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain
#
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
#
# debugger_command =
# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
# -dmS $process_name gdb $daemon_directory/$process_name
# $process_id & sleep 1
# INSTALL-TIME CONFIGURATION INFORMATION
#
# The following parameters are used when installing a new Postfix version.
#
# sendmail_path: The full pathname of the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
#
sendmail_path = /usr/sbin/sendmail.postfix
# newaliases_path: The full pathname of the Postfix newaliases command.
# This is the Sendmail-compatible command to build alias databases.
#
newaliases_path = /usr/bin/newaliases.postfix
# mailq_path: The full pathname of the Postfix mailq command. This
# is the Sendmail-compatible mail queue listing command.
#
mailq_path = /usr/bin/mailq.postfix
# setgid_group: The group for mail submission and queue management
# commands. This must be a group name with a numerical group ID that
# is not shared with other accounts, not even with the Postfix account.
#
setgid_group = postdrop
# html_directory: The location of the Postfix HTML documentation.
#
html_directory = no
# manpage_directory: The location of the Postfix on-line manual pages.
#
manpage_directory = /usr/share/man
# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory = /usr/share/doc/postfix-2.8.4/samples
# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.8.4/README_FILES
virtual_mailbox_domains = $virtual_mailbox_maps,
hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox
transport_maps = hash:/var/spool/postfix/plesk/transport
smtpd_tls_cert_file = /etc/postfix/postfix_default.pem
smtpd_tls_key_file = $smtpd_tls_cert_file
smtpd_tls_security_level = may
smtpd_use_tls = yes
smtp_tls_security_level = may
smtp_use_tls = no
smtpd_timeout = 3600s
smtpd_proxy_timeout = 3600s
disable_vrfy_command = yes
mynetworks = 127.0.0.0/8, [::1]/128, xxx.xxx.xxx.xxx/32
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,
reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, permit
smtpd_sender_restrictions = permit_mynetworks,
reject_unknown_sender_domain, reject_unknown_address,
reject_unlisted_sender, reject_non_fqdn_sender,
reject_unknown_sender_domain, permit
# smtpd_client_restrictions = permit_mynetworks, reject_rbl_client
sbl.spamhaus.org
smtp_send_xforward_command = yes
smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated, reject_unauth_destination, permit
# smtpd_recipient_restrictions = reject_unauth_pipelining,
reject_non_fqdn_recipient, reject_unknown_recipient_domain,
permit_mynetworks, reject_unauth_destination, check_sender_access
hash:/etc/postfix/sender_access, reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net, check_policy_service
unix:postgrey/socket, permit
virtual_mailbox_base = /var/qmail/mailnames
virtual_uid_maps = static:110
virtual_gid_maps = static:30
smtpd_milters = inet:localhost:12768
non_smtpd_milters = inet:localhost:12768
sender_dependent_default_transport_maps =
hash:/var/spool/postfix/plesk/sdd_transport_maps
virtual_transport = plesk_virtual
plesk_virtual_destination_recipient_limit = 1
mailman_destination_recipient_limit = 1
myhostname = mail.myinternet.gr
milter_connect_macros = j {daemon_name} v
milter_data_macros = i
milter_end_of_data_macros = i
milter_end_of_header_macros = i
milter_helo_macros = {tls_version} {cipher} {cipher_bits} {cert_subject}
{cert_issuer}
milter_macro_daemon_name = $myhostname
milter_macro_v = $mail_name $mail_version
milter_mail_macros = i {auth_type} {auth_authen} {auth_author} {mail_addr}
milter_rcpt_macros = i {rcpt_addr}
message_size_limit = 40960000
Thank you for your time
Monday, 30 September 2013
If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?
If $ a \mid bc $ then $\frac{a}{\gcd(a,b)} \mid c$?
Prove or reject this statement:
If $ a \mid bc $ then $\displaystyle \frac{a}{\gcd(a,b)} \mid c$
Prove or reject this statement:
If $ a \mid bc $ then $\displaystyle \frac{a}{\gcd(a,b)} \mid c$
Can a custom module have more than one namespace=?iso-8859-1?Q?=3F_=96_magento.stackexchange.com?=
Can a custom module have more than one namespace? – magento.stackexchange.com
Is it fine to have more than one namespaces for a custom module? I haven't
tried yet. But for some situations it's better if we can have this
feature. Any suggestion will be appreciated. Example: …
Is it fine to have more than one namespaces for a custom module? I haven't
tried yet. But for some situations it's better if we can have this
feature. Any suggestion will be appreciated. Example: …
Oracle forms migrated from 10g to 11g
Oracle forms migrated from 10g to 11g
Once exported from oracle 10g to 11g, It is saying some java beans are
missing in the form. Is there something we need to change the FORM beans
path in new version.If not, Where are we mentioning the path for java
beans in reports.
Once exported from oracle 10g to 11g, It is saying some java beans are
missing in the form. Is there something we need to change the FORM beans
path in new version.If not, Where are we mentioning the path for java
beans in reports.
Javascript: get *updated* value of textarea
Javascript: get *updated* value of textarea
I have atext area on my page.I am filling it up from some data at page
load.Then user changes the data in textarea and I alert the text of
textarea.but I am getting the same value in alert which was initially
loaded in text area.It's not updating at all.
html:
<textarea rows="8" style="width: 60%" id="cmds"></textarea>
<input type="button" class="btn" value="alert" onclick="alertCmds()" />
javascript"
$.post('/AutoRegress/AutoRegress?cmd=cmdlist'{url:$('#url').val(),revId:$('#revId').val()},
function(data) {
$("#cmds").val(data.replace(/,/g,"\n"));
});
fuction alertCmds(){
alert($('#cmds').text());
}
I have atext area on my page.I am filling it up from some data at page
load.Then user changes the data in textarea and I alert the text of
textarea.but I am getting the same value in alert which was initially
loaded in text area.It's not updating at all.
html:
<textarea rows="8" style="width: 60%" id="cmds"></textarea>
<input type="button" class="btn" value="alert" onclick="alertCmds()" />
javascript"
$.post('/AutoRegress/AutoRegress?cmd=cmdlist'{url:$('#url').val(),revId:$('#revId').val()},
function(data) {
$("#cmds").val(data.replace(/,/g,"\n"));
});
fuction alertCmds(){
alert($('#cmds').text());
}
Sunday, 29 September 2013
Recurrence Relations and drawing Recursion trees
Recurrence Relations and drawing Recursion trees
Here is the algorithm
Algorithm Mystery(A: Array [i..j] of integer) i & j are array starting and
ending indexes
if i=j then return A[i]
else
k=i+floor((j-i)/2)
temp1= Mystery(A[i..k])
temp2= Mystery(A[(k+1)..j]
if temp1<temp2 then return temp1 else return temp2
I believe the complexity is: T(1) = c T(n) = 2T(n/2) + n
but from here I'm not sure where to go all the examples have the second
equation ending with cn so i have no idea how to draw the tree. Did i
solve the recursion wrong? I just need some help getting on the right
direction.
Here is the algorithm
Algorithm Mystery(A: Array [i..j] of integer) i & j are array starting and
ending indexes
if i=j then return A[i]
else
k=i+floor((j-i)/2)
temp1= Mystery(A[i..k])
temp2= Mystery(A[(k+1)..j]
if temp1<temp2 then return temp1 else return temp2
I believe the complexity is: T(1) = c T(n) = 2T(n/2) + n
but from here I'm not sure where to go all the examples have the second
equation ending with cn so i have no idea how to draw the tree. Did i
solve the recursion wrong? I just need some help getting on the right
direction.
Django REST Framework: object is None only on one attribute, but not other
Django REST Framework: object is None only on one attribute, but not other
I have been having trouble understanding why the object (obj) passed into
field_to_native() changes from Nonetype to a correct object once I change
the attribute...
Here's the original issue: Splitting model instance for serializer into 3
different fields
mariodev from stackoverflow helped me on the original issue, but a strange
bug both of us cannot figure out:
Here's the code where it seems to have the problem:
COORD = dict(x=0, y=1, z=2)
class CoordField(serializers.Field):
def field_to_native(self, obj, field_name):
#retrieve and split coords
coor = obj.xyz.split('x')
return int(coor[COORD[field_name]])
class NoteSerializer(serializers.ModelSerializer):
owner = serializers.Field(source='owner.username')
firstname = serializers.Field(source='owner.first_name')
lastname = serializers.Field(source='owner.last_name')
x = CoordField()
y = CoordField()
z = CoordField()
class Meta:
model = Note
fields =
('id','owner','firstname','lastname','text','color','time','x', 'y',
'z')
xyz is a instance in the model Note. According to the traceback, when I do
obj.xyz, the obj = None.
Weirdly, if I do obj.color, the obj returns correctly (Note: someuser)
I don't understand how the obj can change just by changing the attribute.
What's beyond me is that the JSON data 'x' 'y' and 'z' ARE being passed to
the view, and my div boxes get the correct left, top, and z-index CSS
data. If this works, why am I getting an error?
If there's an error, why is the data still getting through?
style="left: 343px; top: 110px; z-index: 3;"
As you can see, the x,y,z DID pass through.
Any enlightenment would be wonderful! Thanks a bunch!
Here's the traceback in text view:
Traceback: File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response 140. response = response.render() File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/template/response.py"
in render 105. self.content = self.rendered_content File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/response.py"
in rendered_content 59. ret = renderer.render(self.data, media_type,
context) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in render 582. post_form = self.get_rendered_html_form(view, 'POST',
request) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in get_rendered_html_form 485. data = serializer.data File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in data 510. self._data = self.to_native(obj) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in to_native 309. value = field.field_to_native(obj, field_name) File
"/home1/thecupno/django/notes/desk/serializers.py" in field_to_native 10.
coor = obj.xyz#.split('x') <-- I commented out .split, and the problem
still persists.
Exception Type: AttributeError at /desk/restnote/ Exception Value:
'NoneType' object has no attribute 'xyz'
I have been having trouble understanding why the object (obj) passed into
field_to_native() changes from Nonetype to a correct object once I change
the attribute...
Here's the original issue: Splitting model instance for serializer into 3
different fields
mariodev from stackoverflow helped me on the original issue, but a strange
bug both of us cannot figure out:
Here's the code where it seems to have the problem:
COORD = dict(x=0, y=1, z=2)
class CoordField(serializers.Field):
def field_to_native(self, obj, field_name):
#retrieve and split coords
coor = obj.xyz.split('x')
return int(coor[COORD[field_name]])
class NoteSerializer(serializers.ModelSerializer):
owner = serializers.Field(source='owner.username')
firstname = serializers.Field(source='owner.first_name')
lastname = serializers.Field(source='owner.last_name')
x = CoordField()
y = CoordField()
z = CoordField()
class Meta:
model = Note
fields =
('id','owner','firstname','lastname','text','color','time','x', 'y',
'z')
xyz is a instance in the model Note. According to the traceback, when I do
obj.xyz, the obj = None.
Weirdly, if I do obj.color, the obj returns correctly (Note: someuser)
I don't understand how the obj can change just by changing the attribute.
What's beyond me is that the JSON data 'x' 'y' and 'z' ARE being passed to
the view, and my div boxes get the correct left, top, and z-index CSS
data. If this works, why am I getting an error?
If there's an error, why is the data still getting through?
style="left: 343px; top: 110px; z-index: 3;"
As you can see, the x,y,z DID pass through.
Any enlightenment would be wonderful! Thanks a bunch!
Here's the traceback in text view:
Traceback: File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response 140. response = response.render() File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/django/template/response.py"
in render 105. self.content = self.rendered_content File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/response.py"
in rendered_content 59. ret = renderer.render(self.data, media_type,
context) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in render 582. post_form = self.get_rendered_html_form(view, 'POST',
request) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/renderers.py"
in get_rendered_html_form 485. data = serializer.data File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in data 510. self._data = self.to_native(obj) File
"/home1/thecupno/python2.7/lib/python2.7/site-packages/rest_framework/serializers.py"
in to_native 309. value = field.field_to_native(obj, field_name) File
"/home1/thecupno/django/notes/desk/serializers.py" in field_to_native 10.
coor = obj.xyz#.split('x') <-- I commented out .split, and the problem
still persists.
Exception Type: AttributeError at /desk/restnote/ Exception Value:
'NoneType' object has no attribute 'xyz'
Rails controller action behavior without respond_to
Rails controller action behavior without respond_to
Rails Scaffold generator create some actions in a controller with
respond_to and some without it.
For example:
GET /replaces/new
GET /replaces/new.json
def new
@replace = Replace.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @replace }
end
end
GET /replaces/1/edit
def edit
@replace = Replace.find(params[:id])
end
I understand that Rails renders the view that has the same name as the
action. If I have multiple views with the same name (in different
formats), I have to specify which one you want in the request and use the
respond_to method to respond accordingly.
Questions:
Why the Scaffold generator create some actions without respond_to ?
What will be the behavior if there no respond_to and requests are coming
with different format? HTML? AJAX?
Rails Scaffold generator create some actions in a controller with
respond_to and some without it.
For example:
GET /replaces/new
GET /replaces/new.json
def new
@replace = Replace.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @replace }
end
end
GET /replaces/1/edit
def edit
@replace = Replace.find(params[:id])
end
I understand that Rails renders the view that has the same name as the
action. If I have multiple views with the same name (in different
formats), I have to specify which one you want in the request and use the
respond_to method to respond accordingly.
Questions:
Why the Scaffold generator create some actions without respond_to ?
What will be the behavior if there no respond_to and requests are coming
with different format? HTML? AJAX?
Java Server Faces error when trying to use an if method in my Bean class
Java Server Faces error when trying to use an if method in my Bean class
Hey im trying to set up a voting app that will display whether the user is
able to vote or not using an if statement in my bean class but this Unable
to find matching navigation case with from-view-id '/home.xhtml' for
action '#{user.checkAge(user.age)}' with outcome 'Invalid User, Please Try
Again!!!'. Im not very understanding of Java Server Faces yet and ive
tried messing around with the config files and googling the error but i
cant fix it. Can anyone help me please.
Here is my code:
**
Home.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Results Page</title>
</head>
<body>
<h:form>
Name: <h:outputText id="outTxt" value="#{user.name}"/><br></br>
Age: <h:outputText id="outTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check"
action="#{user.checkAge(user.age)}"/>
</h:form>
</body>
</html>
**
index.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Home Page</title>
</h:head>
<h:body>
<h:body>
<h:form>
Name: <h:inputText id="inTxt" value="#{user.name}"/><br></br>
Age: <h:inputText id="inTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="home"/>
</h:form>
</h:body>
</h:body>
</html>
**
User.java
**
package MyPackage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User
{
private String name;
private int age;
private String msg;
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String checkAge(int checkAgeVoter)
{
if(checkAgeVoter >= 18)
{
msg = "Valid User, Access Granted!!!";
}
else
{
msg = "Invalid User, Please Try Again!!!";
}
return msg;
}
}
Hey im trying to set up a voting app that will display whether the user is
able to vote or not using an if statement in my bean class but this Unable
to find matching navigation case with from-view-id '/home.xhtml' for
action '#{user.checkAge(user.age)}' with outcome 'Invalid User, Please Try
Again!!!'. Im not very understanding of Java Server Faces yet and ive
tried messing around with the config files and googling the error but i
cant fix it. Can anyone help me please.
Here is my code:
**
Home.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Results Page</title>
</head>
<body>
<h:form>
Name: <h:outputText id="outTxt" value="#{user.name}"/><br></br>
Age: <h:outputText id="outTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check"
action="#{user.checkAge(user.age)}"/>
</h:form>
</body>
</html>
**
index.xhtml
**
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Home Page</title>
</h:head>
<h:body>
<h:body>
<h:form>
Name: <h:inputText id="inTxt" value="#{user.name}"/><br></br>
Age: <h:inputText id="inTxt2" value="#{user.age}"/><br></br>
<h:commandButton id="cmdBtn" value="Check" action="home"/>
</h:form>
</h:body>
</h:body>
</html>
**
User.java
**
package MyPackage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User
{
private String name;
private int age;
private String msg;
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String checkAge(int checkAgeVoter)
{
if(checkAgeVoter >= 18)
{
msg = "Valid User, Access Granted!!!";
}
else
{
msg = "Invalid User, Please Try Again!!!";
}
return msg;
}
}
Saturday, 28 September 2013
Only Print DataGridView in windows forms
Only Print DataGridView in windows forms
i want to ask, how do i print only DataGridView in windows forms and using
my own format. I also didn't know how to print a file in windows forms.
Could you guys help me? This will be my format when print:
And here is my DataGridView:
NOTE: This is just an example (only the DataGridView, but for the format i
want to when print be like that.
i want to ask, how do i print only DataGridView in windows forms and using
my own format. I also didn't know how to print a file in windows forms.
Could you guys help me? This will be my format when print:
And here is my DataGridView:
NOTE: This is just an example (only the DataGridView, but for the format i
want to when print be like that.
My background isn't spanning horizontally
My background isn't spanning horizontally
I have this code, the only code on the site that would be affecting the
background. I had Eric Meyer's CSS reset on, but commented it out to see.
It made no difference. The only code I have left is this.
* {
margin: 0;
padding: 0;
}
body {
background: url("../images/bg.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I tried many different things to get it to touch the side of the browsers,
but there remains an annoying margin or something on the sides. Any ideas
on how to get rid of this?
Here's what it looks like:
I have this code, the only code on the site that would be affecting the
background. I had Eric Meyer's CSS reset on, but commented it out to see.
It made no difference. The only code I have left is this.
* {
margin: 0;
padding: 0;
}
body {
background: url("../images/bg.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I tried many different things to get it to touch the side of the browsers,
but there remains an annoying margin or something on the sides. Any ideas
on how to get rid of this?
Here's what it looks like:
How to close previous popovers in fullCalendar?
How to close previous popovers in fullCalendar?
I am using fullCalendar in my website together with Bootstrap so that
everytime I click on a day in month view, there is a popover to add event,
just like that in Google Calendar. Here is my code
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
height: height,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayClick: function( date, allDay, jsEvent, view ){
$(this).children().popover({
title: 'haha',
placement: 'right',
content: 'haha',html : true, container: 'body'
});
$(this).children().popover('show');
}
})
The code should be right before $(this).children().popover({ so that it
closes all previously fired popover.
However, exactly, what code should I use to achieve this?
Thank you!
I am using fullCalendar in my website together with Bootstrap so that
everytime I click on a day in month view, there is a popover to add event,
just like that in Google Calendar. Here is my code
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
height: height,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayClick: function( date, allDay, jsEvent, view ){
$(this).children().popover({
title: 'haha',
placement: 'right',
content: 'haha',html : true, container: 'body'
});
$(this).children().popover('show');
}
})
The code should be right before $(this).children().popover({ so that it
closes all previously fired popover.
However, exactly, what code should I use to achieve this?
Thank you!
How to get rid of small gaps between horizontally aligned images?
How to get rid of small gaps between horizontally aligned images?
pPlease see a href=http://www.rcblue.com/test/Toby.html
rel=nofollowhttp://www.rcblue.com/test/Toby.html/a . There are very narrow
vertical gaps between the images. How to get rid of them?/p
pPlease see a href=http://www.rcblue.com/test/Toby.html
rel=nofollowhttp://www.rcblue.com/test/Toby.html/a . There are very narrow
vertical gaps between the images. How to get rid of them?/p
Friday, 27 September 2013
Java RegEX To Split and Reverse String
Java RegEX To Split and Reverse String
I have a Java String "test/this/string" that I want to reverse to
"string/this/test" using a regular expression or the most efficient Java
algorithm. The way I know is to use the split method, loop over the array
and rebuild the string manually. The number of "/" can vary and doesn't
occur a fixed number of times. Any ideas?
I have a Java String "test/this/string" that I want to reverse to
"string/this/test" using a regular expression or the most efficient Java
algorithm. The way I know is to use the split method, loop over the array
and rebuild the string manually. The number of "/" can vary and doesn't
occur a fixed number of times. Any ideas?
.htaccess remove .html file/directory priority rewrite
.htaccess remove .html file/directory priority rewrite
I'm trying to rewrite so you can access files without .html and without
adding a trailing slash. here's the code being used:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*?)/?$
RewriteCond %{DOCUMENT_ROOT}/%1.html -f
RewriteRule ^(.*?)/?$ $1.html
But for my file structure on the server where I have this:
/public_html
..
/beginners
beginners.html
and inside /beginners folder there's other files, e.g.
/beginners/page1.html
I need rewrites to work like this:
if user inputs url: website.com/beginners - the server would return the
contents of file beginners.html currently it returns the contents of the
directory /beginners . so i need the server to first check if
beginners.html exists, if yes - then server serves beginners.html not the
directory /beginners
if the user accesses url website.com/beginners/page1 the server should
first check up if page1.html exists in the folder beginners and if it
finds the file page1.html then it serves the contents of the file
page1.html
can this be done?
I'm trying to rewrite so you can access files without .html and without
adding a trailing slash. here's the code being used:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*?)/?$
RewriteCond %{DOCUMENT_ROOT}/%1.html -f
RewriteRule ^(.*?)/?$ $1.html
But for my file structure on the server where I have this:
/public_html
..
/beginners
beginners.html
and inside /beginners folder there's other files, e.g.
/beginners/page1.html
I need rewrites to work like this:
if user inputs url: website.com/beginners - the server would return the
contents of file beginners.html currently it returns the contents of the
directory /beginners . so i need the server to first check if
beginners.html exists, if yes - then server serves beginners.html not the
directory /beginners
if the user accesses url website.com/beginners/page1 the server should
first check up if page1.html exists in the folder beginners and if it
finds the file page1.html then it serves the contents of the file
page1.html
can this be done?
java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_id]
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [_id]
After another SO poster resolved my issue to insert a List[DBObject] ...
// Bulk insert all documents
collection.insert(MongoDBList(docs)) // docs is List[DBObject]
Now, I'm seeing this error when trying to insert.
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [_id]
I've checked out the exactly named post, but I'm not sure how to apply the
answer to my problem.
numeric keys, not: [_id]
After another SO poster resolved my issue to insert a List[DBObject] ...
// Bulk insert all documents
collection.insert(MongoDBList(docs)) // docs is List[DBObject]
Now, I'm seeing this error when trying to insert.
java.lang.IllegalArgumentException: BasicBSONList can only work with
numeric keys, not: [_id]
I've checked out the exactly named post, but I'm not sure how to apply the
answer to my problem.
Ruby - Scripting language or Object Oriented Language?
Ruby - Scripting language or Object Oriented Language?
Is Ruby a scripting language or an object oriented language that is
capable of producing complex programs?
Is Ruby a scripting language or an object oriented language that is
capable of producing complex programs?
UIGestureRecognizer with a touch moving off UIView
UIGestureRecognizer with a touch moving off UIView
I have a UILongPressGestureREcognizer with a minimum press length of 0
seconds. On UIGestureRecognizerStateStart I alter the UIView. On
UIGestureRecognizerStateEnded, I run the code for what ever the press is
suppose to do.
-(IBAction)longPressDetected:(UILongPressGestureRecognizer *)recognizer {
static NSTimer *timer = nil;
if (recognizer.state == UIGestureRecognizerStateBegan) {
// alter look of UIView
}
else if (recognizer.state == UIGestureRecognizerStateEnded) {
// do something
// change look back to original state
}
}
I am running into an issue where if the touch starts on the UIView and if
the touch is dragged outside of the UIView and is lifted, the
UIGestureRecognizerStateEnded still fires.
I need to be able to handle a touch inside the UIView, the user drag
outside of the UIView and to cancel it.
I know a UIButton can do it, but it does not fulfill all the needs I have.
How can I cancel a touch if the touch is dragged outside of the UIView?
I have a UILongPressGestureREcognizer with a minimum press length of 0
seconds. On UIGestureRecognizerStateStart I alter the UIView. On
UIGestureRecognizerStateEnded, I run the code for what ever the press is
suppose to do.
-(IBAction)longPressDetected:(UILongPressGestureRecognizer *)recognizer {
static NSTimer *timer = nil;
if (recognizer.state == UIGestureRecognizerStateBegan) {
// alter look of UIView
}
else if (recognizer.state == UIGestureRecognizerStateEnded) {
// do something
// change look back to original state
}
}
I am running into an issue where if the touch starts on the UIView and if
the touch is dragged outside of the UIView and is lifted, the
UIGestureRecognizerStateEnded still fires.
I need to be able to handle a touch inside the UIView, the user drag
outside of the UIView and to cancel it.
I know a UIButton can do it, but it does not fulfill all the needs I have.
How can I cancel a touch if the touch is dragged outside of the UIView?
InteliJ idea gui designer + maven
InteliJ idea gui designer + maven
I have a project created with help of GUI designer. Here is code of main
form.
public class MainForm {
MainForm() {
directLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
}
}
});
crossLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
}
public JPanel getMainPanel() {
return mainPanel;
}
private void createUIComponents() {
drawingPanel = new DrawingPanel();
}
private JPanel mainPanel;
private JComboBox directDirectionCombobox;
private JButton directLineOkButton;
private JButton crossLineOkButton;
private JComboBox crossLineComboBox;
private JTextField crossLineSizeValue;
private JButton clearButton;
private JLabel directLineLabel;
private JPanel directLinePanel;
private JLabel crossLineLabel;
private JPanel crossLinePanel;
private JPanel okClearButtonPanel;
private JTextField directLineSizeValue;
private JButton saveButton;
private JPanel drawingPanel;
private JButton cancelButton;
}
It works fine. Jar file generates fine, here code of pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DOC</groupId>
<artifactId>DOC</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I try to run jar file there is a mistake.
Exception in thread "main" java.lang.NullPointerException
at MainForm.<init>(MainForm.java:14)
at Main.main(Main.java:13)
It show that mistake is at the line where directLineOkButton listener is
created. I create listener like said here:
http://www.jetbrains.com/idea/training/demos/GUI_Designer/GUI_Designer.html
in constructor using cmd+o. Here is code of xml of form:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1"
bind-to-class="MainForm">
<grid id="27dc6" binding="mainPanel" layout-manager="FormLayout">
<rowspec value="center:23px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:47px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:7dlu:noGrow"/>
<rowspec value="center:25px:noGrow"/>
<rowspec value="top:174dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:452px:noGrow"/>
<constraints>
<xy x="20" y="20" width="797" height="453"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3b663" class="javax.swing.JLabel"
binding="directLineLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Direct Line"/>
</properties>
</component>
<grid id="499e0" binding="directLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="1" column="0" row-span="2" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c383d" class="javax.swing.JComboBox"
binding="directDirectionCombobox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="true"/>
<model>
<item value="Ââåðõ"/>
<item value="Âíèç"/>
<item value="Âïðàâî"/>
<item value="Âëåâî"/>
</model>
</properties>
</component>
<component id="17aa1" class="javax.swing.JTextField"
binding="directLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="44fc7" class="javax.swing.JButton"
binding="directLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<component id="5a571" class="javax.swing.JLabel"
binding="crossLineLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Cross Line"/>
</properties>
</component>
<grid id="77f1a" binding="crossLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="32368" class="javax.swing.JComboBox"
binding="crossLineComboBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<model>
<item value="Ââåðõ-âïðàâî"/>
<item value="Ââåðõ-âëåâî"/>
<item value="Âíèç-âïðàâî"/>
<item value="Âíèç-âëåâî"/>
</model>
</properties>
</component>
<component id="dbf23" class="javax.swing.JTextField"
binding="crossLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="c5c8a" class="javax.swing.JButton"
binding="crossLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<grid id="53bbc" binding="okClearButtonPanel"
layout-manager="FormLayout">
<rowspec value="center:d:noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="8" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
<border type="none"/>
<children>
<component id="41ba7" class="javax.swing.JButton"
binding="saveButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Ñîõðàíèòü"/>
</properties>
</component>
<component id="a6bf6" class="javax.swing.JButton"
binding="clearButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Î÷èñòèòü"/>
</properties>
</component>
<component id="40f1c" class="javax.swing.JButton"
binding="cancelButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Îòìåíèòü"/>
</properties>
</component>
</children>
</grid>
<grid id="2e94e" binding="drawingPanel" custom-create="true"
layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:d:grow"/>
<constraints>
<grid row="0" column="2" row-span="11" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<background color="-1"/>
</properties>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
I have a project created with help of GUI designer. Here is code of main
form.
public class MainForm {
MainForm() {
directLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
}
}
});
crossLineOkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//some action
});
}
public JPanel getMainPanel() {
return mainPanel;
}
private void createUIComponents() {
drawingPanel = new DrawingPanel();
}
private JPanel mainPanel;
private JComboBox directDirectionCombobox;
private JButton directLineOkButton;
private JButton crossLineOkButton;
private JComboBox crossLineComboBox;
private JTextField crossLineSizeValue;
private JButton clearButton;
private JLabel directLineLabel;
private JPanel directLinePanel;
private JLabel crossLineLabel;
private JPanel crossLinePanel;
private JPanel okClearButtonPanel;
private JTextField directLineSizeValue;
private JButton saveButton;
private JPanel drawingPanel;
private JButton cancelButton;
}
It works fine. Jar file generates fine, here code of pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DOC</groupId>
<artifactId>DOC</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I try to run jar file there is a mistake.
Exception in thread "main" java.lang.NullPointerException
at MainForm.<init>(MainForm.java:14)
at Main.main(Main.java:13)
It show that mistake is at the line where directLineOkButton listener is
created. I create listener like said here:
http://www.jetbrains.com/idea/training/demos/GUI_Designer/GUI_Designer.html
in constructor using cmd+o. Here is code of xml of form:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1"
bind-to-class="MainForm">
<grid id="27dc6" binding="mainPanel" layout-manager="FormLayout">
<rowspec value="center:23px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:47px:noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:7dlu:noGrow"/>
<rowspec value="center:25px:noGrow"/>
<rowspec value="top:174dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:452px:noGrow"/>
<constraints>
<xy x="20" y="20" width="797" height="453"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3b663" class="javax.swing.JLabel"
binding="directLineLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Direct Line"/>
</properties>
</component>
<grid id="499e0" binding="directLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="1" column="0" row-span="2" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c383d" class="javax.swing.JComboBox"
binding="directDirectionCombobox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="true"/>
<model>
<item value="Ââåðõ"/>
<item value="Âíèç"/>
<item value="Âïðàâî"/>
<item value="Âëåâî"/>
</model>
</properties>
</component>
<component id="17aa1" class="javax.swing.JTextField"
binding="directLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="44fc7" class="javax.swing.JButton"
binding="directLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<component id="5a571" class="javax.swing.JLabel"
binding="crossLineLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Cross Line"/>
</properties>
</component>
<grid id="77f1a" binding="crossLinePanel" layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:98px:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:80px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="32368" class="javax.swing.JComboBox"
binding="crossLineComboBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="2" anchor="8" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<model>
<item value="Ââåðõ-âïðàâî"/>
<item value="Ââåðõ-âëåâî"/>
<item value="Âíèç-âïðàâî"/>
<item value="Âíèç-âëåâî"/>
</model>
</properties>
</component>
<component id="dbf23" class="javax.swing.JTextField"
binding="crossLineSizeValue">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="6" anchor="8" fill="1"
indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
</component>
<component id="c5c8a" class="javax.swing.JButton"
binding="crossLineOkButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<grid id="53bbc" binding="okClearButtonPanel"
layout-manager="FormLayout">
<rowspec value="center:d:noGrow"/>
<colspec value="fill:d:noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<constraints>
<grid row="8" column="0" row-span="1" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
<border type="none"/>
<children>
<component id="41ba7" class="javax.swing.JButton"
binding="saveButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Ñîõðàíèòü"/>
</properties>
</component>
<component id="a6bf6" class="javax.swing.JButton"
binding="clearButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Î÷èñòèòü"/>
</properties>
</component>
<component id="40f1c" class="javax.swing.JButton"
binding="cancelButton">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1"
vsize-policy="0" hsize-policy="3" anchor="0" fill="1"
indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Îòìåíèòü"/>
</properties>
</component>
</children>
</grid>
<grid id="2e94e" binding="drawingPanel" custom-create="true"
layout-manager="FormLayout">
<rowspec value="center:d:grow"/>
<colspec value="fill:d:grow"/>
<constraints>
<grid row="0" column="2" row-span="11" col-span="1"
vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0"
use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<background color="-1"/>
</properties>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
How to properly read SQL Server syntax?
How to properly read SQL Server syntax?
In the MSDN Library or the Technet website, Microsoft tend to use a pseudo
syntax in explaining how to use T-SQL statements with all available
options. Here is a sample taking from the Technet page on UPDATE
STATISTICS :
UPDATE STATISTICS table_or_indexed_view_name
[
{
{ index_or_statistics__name }
| ( { index_or_statistics_name } [ ,...n ] )
}
]
[ WITH
[
FULLSCAN
| SAMPLE number { PERCENT | ROWS }
| RESAMPLE
| <update_stats_stream_option> [ ,...n ]
]
[ [ , ] [ ALL | COLUMNS | INDEX ]
[ [ , ] NORECOMPUTE ]
] ;
<update_stats_stream_option> ::=
[ STATS_STREAM = stats_stream ]
[ ROWCOUNT = numeric_constant ]
[ PAGECOUNT = numeric_contant ]
How to properly read such description and quickly figure out what is
required and what is optional and a clean way to write your query?
In the MSDN Library or the Technet website, Microsoft tend to use a pseudo
syntax in explaining how to use T-SQL statements with all available
options. Here is a sample taking from the Technet page on UPDATE
STATISTICS :
UPDATE STATISTICS table_or_indexed_view_name
[
{
{ index_or_statistics__name }
| ( { index_or_statistics_name } [ ,...n ] )
}
]
[ WITH
[
FULLSCAN
| SAMPLE number { PERCENT | ROWS }
| RESAMPLE
| <update_stats_stream_option> [ ,...n ]
]
[ [ , ] [ ALL | COLUMNS | INDEX ]
[ [ , ] NORECOMPUTE ]
] ;
<update_stats_stream_option> ::=
[ STATS_STREAM = stats_stream ]
[ ROWCOUNT = numeric_constant ]
[ PAGECOUNT = numeric_contant ]
How to properly read such description and quickly figure out what is
required and what is optional and a clean way to write your query?
Thursday, 26 September 2013
is it possible create a sql view from "horizontal" to "vertical"
is it possible create a sql view from "horizontal" to "vertical"
please see my attached below: my actual data will be store in table 1, can
I create a view that display data like table 2?
please see my attached below: my actual data will be store in table 1, can
I create a view that display data like table 2?
Wednesday, 25 September 2013
Controlling CSS using AngularJS
Controlling CSS using AngularJS
I am trying to control CSS through AngularJS. I am using ng-class and
ng-click for this purpose ..... I have made two function showError and
showWarning for this purpose. I am try to change CSS through setting their
properties true and false respectively
--------CSS---------
.error {
background-color: red;
}
.warning {
background-color: orange;
}
-------HTML---------
<div>
<h2> {{ message }} </h2>
<ul>
<li class="menu-disabled-{{ isDisabled }}" ng-click="stun()">
Stun</li>
</ul>
<div class='{ warning : {{ isWarning }}, error : {{ isError }} }'>
{{ messageText }}</div>
<button ng-click="showError()"> Simulate Error</button>
<button ng-click="showWarning()">Simulate Warning</button>
</div>
-------JS-----------
$scope.isError = false;
$scope.isWaring = false;
$scope.showError = function(){
console.log("error here");
$scope.messageText = "This is an error";
$scope.isError = true;
$scope.isWaring = false;
}//showError
$scope.showWarning = function() {
console.log("warning here");
$scope.messageText = "Just a Warning, Carry ON !!!";
$scope.isError = false;
$scope.isWaring = true;
}//showWarning
I am successful to access the function and printing the messageText using
ng-click but can't change the CSS properties////
I am trying to control CSS through AngularJS. I am using ng-class and
ng-click for this purpose ..... I have made two function showError and
showWarning for this purpose. I am try to change CSS through setting their
properties true and false respectively
--------CSS---------
.error {
background-color: red;
}
.warning {
background-color: orange;
}
-------HTML---------
<div>
<h2> {{ message }} </h2>
<ul>
<li class="menu-disabled-{{ isDisabled }}" ng-click="stun()">
Stun</li>
</ul>
<div class='{ warning : {{ isWarning }}, error : {{ isError }} }'>
{{ messageText }}</div>
<button ng-click="showError()"> Simulate Error</button>
<button ng-click="showWarning()">Simulate Warning</button>
</div>
-------JS-----------
$scope.isError = false;
$scope.isWaring = false;
$scope.showError = function(){
console.log("error here");
$scope.messageText = "This is an error";
$scope.isError = true;
$scope.isWaring = false;
}//showError
$scope.showWarning = function() {
console.log("warning here");
$scope.messageText = "Just a Warning, Carry ON !!!";
$scope.isError = false;
$scope.isWaring = true;
}//showWarning
I am successful to access the function and printing the messageText using
ng-click but can't change the CSS properties////
Thursday, 19 September 2013
DLL issue. C# not recognizing DLL file, or its just me
DLL issue. C# not recognizing DLL file, or its just me
I'm assigned a task to use a DLL file in C#. I have created the DLL file
(Prog1210.dll) and have added it as a reference into the Solution explorer
in C#. The DLL file has a variable txtNumber1 which is trying to be
accessed in this main class.
Just wondering why it recognizes ValidateTextbox in the DLL in this class
form, but says it doesn't recognize Prog1210 in the using statement, and
doesn't recognize txtNumber1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Prog1210;
namespace StaticClass
{
class Class1
{
private void btnValidate_Click(object sender, EventArgs e)
{
// Use the ValidateTexbox class that has been added to this project
if (ValidateTextbox.IsPresent(txtNumber1) &&
ValidateTextbox.IsDouble(txtNumber1) &&
ValidateTextbox.IsWithinRange(txtNumber1, 1.0, 100.0))
{
MessageBox.Show("Textbox value is valid!", "Good Data");
}
else
{
// The ValidateTexbox methods assigns an error message to the Tag
// property of the textbox.
string display = (string)txtNumber1.Tag;
MessageBox.Show(display, "Bad Data");
txtNumber1.Focus();
}
}
}
}`
I'm assigned a task to use a DLL file in C#. I have created the DLL file
(Prog1210.dll) and have added it as a reference into the Solution explorer
in C#. The DLL file has a variable txtNumber1 which is trying to be
accessed in this main class.
Just wondering why it recognizes ValidateTextbox in the DLL in this class
form, but says it doesn't recognize Prog1210 in the using statement, and
doesn't recognize txtNumber1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Prog1210;
namespace StaticClass
{
class Class1
{
private void btnValidate_Click(object sender, EventArgs e)
{
// Use the ValidateTexbox class that has been added to this project
if (ValidateTextbox.IsPresent(txtNumber1) &&
ValidateTextbox.IsDouble(txtNumber1) &&
ValidateTextbox.IsWithinRange(txtNumber1, 1.0, 100.0))
{
MessageBox.Show("Textbox value is valid!", "Good Data");
}
else
{
// The ValidateTexbox methods assigns an error message to the Tag
// property of the textbox.
string display = (string)txtNumber1.Tag;
MessageBox.Show(display, "Bad Data");
txtNumber1.Focus();
}
}
}
}`
Are there any languages with "lateral" assignment operators?
Are there any languages with "lateral" assignment operators?
I don't know a really good name for what I'm talking about, but, most
programming languages use a syntax for assignment statements something
like this:
(variable) (assignment operator) (expression)
And some have some special assignment operators, such as var1 += var2
which is equivalent tovar1 = var1 + var2.
My question is basically, is there any language that would treat += like
above, but also have an =+ operator so that var1 =+ var2 would be
equivalent to var2 = var2 + var1?
Essentially, are there programming languages with "mirrorable" assignment
operators, so that the variable on the right is what gets assignment a new
variable (as opposed to the one on the left)?
Edit:
I suppose a much better example of what I'm referring to would be a
language in which you can have both (variable) (assignment operator)
(expression) and (expression) (assignment operator) (variable) as valid
statements.
I don't know a really good name for what I'm talking about, but, most
programming languages use a syntax for assignment statements something
like this:
(variable) (assignment operator) (expression)
And some have some special assignment operators, such as var1 += var2
which is equivalent tovar1 = var1 + var2.
My question is basically, is there any language that would treat += like
above, but also have an =+ operator so that var1 =+ var2 would be
equivalent to var2 = var2 + var1?
Essentially, are there programming languages with "mirrorable" assignment
operators, so that the variable on the right is what gets assignment a new
variable (as opposed to the one on the left)?
Edit:
I suppose a much better example of what I'm referring to would be a
language in which you can have both (variable) (assignment operator)
(expression) and (expression) (assignment operator) (variable) as valid
statements.
How to put a variable in a Neo4j cypher query for a repository
How to put a variable in a Neo4j cypher query for a repository
I am using spring neo4j. I have a repository class that extends
GraphRepository<T>. I want to delete a specific object based on the uid in
the arguments to the method below.
public interface TypeRepository extends GraphRepository<Type> {
@Query("START n=node:node_auto_index(uid=uidValueYAA)" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(String uidValueYAA);
}
Note: my persisted class has an index annotation like the following:
@GraphId
private Long id;
@Indexed(unique=true) private String uid;
I get the following exception when I use the method like so:
typeRepository.deleteByUid(uid);
//The Exception
string literal or parameter expected|"START
n=node:node_auto_index(uid=uidValueYAA)MATCH n-[r]-()DELETE n, r"|
How can I use the method to delete a specific node based on the uid that I
pass to the method?
I am using spring neo4j. I have a repository class that extends
GraphRepository<T>. I want to delete a specific object based on the uid in
the arguments to the method below.
public interface TypeRepository extends GraphRepository<Type> {
@Query("START n=node:node_auto_index(uid=uidValueYAA)" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(String uidValueYAA);
}
Note: my persisted class has an index annotation like the following:
@GraphId
private Long id;
@Indexed(unique=true) private String uid;
I get the following exception when I use the method like so:
typeRepository.deleteByUid(uid);
//The Exception
string literal or parameter expected|"START
n=node:node_auto_index(uid=uidValueYAA)MATCH n-[r]-()DELETE n, r"|
How can I use the method to delete a specific node based on the uid that I
pass to the method?
DICOM Render not showing all slices (with possible fix)
DICOM Render not showing all slices (with possible fix)
I had 88 DICOM image importing into a 2D Render, but only 8 where showing.
Using Chrome's developer tools I was able to see that all data (88 slices)
were loaded. However, the V.MRI.pixdim was incorrect (reporting a slice
thickness of 9+ where it was 1.5). Tracked the area to parserDC.js line
95. My locations were coming in as text, and when sorted as text were
sorting wrong. The below code seems to have solve my problem on a limited
test basis:
MRI.location.sort(function{a,b} {return a-b; })
Ben
I had 88 DICOM image importing into a 2D Render, but only 8 where showing.
Using Chrome's developer tools I was able to see that all data (88 slices)
were loaded. However, the V.MRI.pixdim was incorrect (reporting a slice
thickness of 9+ where it was 1.5). Tracked the area to parserDC.js line
95. My locations were coming in as text, and when sorted as text were
sorting wrong. The below code seems to have solve my problem on a limited
test basis:
MRI.location.sort(function{a,b} {return a-b; })
Ben
How to see the updated output of index?
How to see the updated output of index?
On creating a index on table, in Sql server how can you see the output of
updated index ?
Query to create an index on the table called [dbo].[Sheet1$] in SQL Server.
create index ix_project_id_PK
on [dbo].[Sheet1$] ( [Project_Key] DESC)
On creating a index on table, in Sql server how can you see the output of
updated index ?
Query to create an index on the table called [dbo].[Sheet1$] in SQL Server.
create index ix_project_id_PK
on [dbo].[Sheet1$] ( [Project_Key] DESC)
May someone explain this html/css code to me?
May someone explain this html/css code to me?
How come when this code is run, it creates a drop-down list like it does?
HTML
<ul id="menu">
<li><a href="">Home</a></li>
<li><a href="">About Us</a>
<ul>
<li><a href="">The Team</a></li>
<li><a href="">History</a></li>
<li><a href="">Vision</a></li>
</ul>
</li>
<li><a href="">Products</a>
<ul>
<li><a href="">Cozy Couch</a></li>
<li><a href="">Great Table</a></li>
<li><a href="">Small Chair</a></li>
<li><a href="">Shiny Shelf</a></li>
<li><a href="">Invisible Nothing</a></li>
</ul>
</li>
<li><a href="">Contact</a>
<ul>
<li><a href="">Online</a></li>
<li><a href="">Right Here</a></li>
<li><a href="">Somewhere Else</a></li>
</ul>
</li>
</ul>
CSS
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: #617F8A;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #617F8A;
}
li:hover li a:hover {
background: #95A9B1;
}
I know all the CSS properties and the HTML tags used in the above code,
but still, for somee reason, I've been trying for the past hour and still
not been able to completely comprehend it. Source: How to make a pure css
based dropdown menu?
How come when this code is run, it creates a drop-down list like it does?
HTML
<ul id="menu">
<li><a href="">Home</a></li>
<li><a href="">About Us</a>
<ul>
<li><a href="">The Team</a></li>
<li><a href="">History</a></li>
<li><a href="">Vision</a></li>
</ul>
</li>
<li><a href="">Products</a>
<ul>
<li><a href="">Cozy Couch</a></li>
<li><a href="">Great Table</a></li>
<li><a href="">Small Chair</a></li>
<li><a href="">Shiny Shelf</a></li>
<li><a href="">Invisible Nothing</a></li>
</ul>
</li>
<li><a href="">Contact</a>
<ul>
<li><a href="">Online</a></li>
<li><a href="">Right Here</a></li>
<li><a href="">Somewhere Else</a></li>
</ul>
</li>
</ul>
CSS
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: #617F8A;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #617F8A;
}
li:hover li a:hover {
background: #95A9B1;
}
I know all the CSS properties and the HTML tags used in the above code,
but still, for somee reason, I've been trying for the past hour and still
not been able to completely comprehend it. Source: How to make a pure css
based dropdown menu?
Why the text fields are not getting disabled="disabled" in colorbox popup?
Why the text fields are not getting disabled="disabled" in colorbox popup?
I'm using PHP, Smarty , jQuery, Colorbox - a jQuery lightbox plugin, etc.
for my website. Now I'm displaying some output in a popup which is
generated by using " Colorbox - a jQuery lightbox plugin". Now I want to
disable all the text fields present in this popup when the form loads but
if I go to the HTML source of page the disabled="disabled" attribute from
the <input> tag gets removed and the text boxes are not getting disabled.
Can you tell me why this is happening? For your reference I'm putting
below the code which will display the data in a Colorbox pop up.
{if $subject_topic_questions}
{foreach from=$subject_topic_questions item=subject_topic_data}
<div class="hidden">
<div id="topics_{$subject_topic_data.subject_id}"
class="c-popup">
<h2 class="c-popup-header">Select Topics</h2>
<div class="c-content">
<input type="hidden"
name="subject_names[{$subject_topic_data.subject_id}]"
id="subject_names"
value="{$subject_topic_data.subject_name}">
<h2 class=""> {$subject_topic_data.subject_name}</h2>
<div class="c-tbl-wrap">
<table width="100%" cellspacing="0"
cellpadding="0" border="0" class="c-tbl">
<tbody>
<tr>
<td>
<p class="custom-form">
<input class="custom-check"
type="checkbox" name="" id="">
<label class="blue">Select All</label>
</p>
</td>
{foreach from=$difficulty_levels item=diff_levels
key=dkey}
<input type="hidden"
name="diff_levels[{$dkey}]"
value="{$diff_levels}">
<td width="22%"
align="center"><strong>{$diff_levels}</strong></td>
{/foreach}
</tr>
{foreach from=$subject_topic_data.topics
item=topic_diff_level_data}
<input type="hidden"
name="subject_{$subject_topic_data.subject_id}_topics[]"
value="{$topic_diff_level_data.topic_id}">
<tr>
<td valign="middle">
<p class="custom-form">
<input type="checkbox"
class="custom-check"
name="{$sheet_type}_topics_{$subject_topic_data.subject_id}[]"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}"
value="{$topic_diff_level_data.topic_id}"
onChange="enable_topic_ques('{$sheet_type}',
'{$subject_topic_data.subject_id}',
'{$topic_diff_level_data.topic_id}');
return false;">
<label>{$topic_diff_level_data.topic_name}</label>
<!-- <input type="hidden"
name="topic_names[{$topic_diff_level_data.topic_id}]"
value="{$topic_diff_level_data.topic_name}">
-->
</p>
</td>
{foreach
from=$topic_diff_level_data.difficulty_level
item=diff_level key=key_diff_lvl}
<td valign="middle">
{if $site_id=='ENTPRM'}<em>Total
{$diff_level.question_count}</em>{/if}
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini"
value="{$diff_level.added_no_questions}"
disabled="disabled">
<input type="hidden"
name="{$sheet_type}_available_questions_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
value="{$diff_level.question_count}">
</td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>
</div>
<p class="center"><a href="#" class="c-btn
fnClosePopup">Done</a> <a href="#"class="c-btn
c-gray-btn fnClosePopup">Cancel</a></p>
</div>
</div>
</div>
{/foreach}
{/if}
The main code you need to consider is as below from the above code:
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini" value="{$diff_level.added_no_questions}"
disabled="disabled">
Can you tell me how the disabled="disabled" attribute gets vanishes after
page load and if there is any way to apply to it, please tell me. Thanks
in advance.
I'm using PHP, Smarty , jQuery, Colorbox - a jQuery lightbox plugin, etc.
for my website. Now I'm displaying some output in a popup which is
generated by using " Colorbox - a jQuery lightbox plugin". Now I want to
disable all the text fields present in this popup when the form loads but
if I go to the HTML source of page the disabled="disabled" attribute from
the <input> tag gets removed and the text boxes are not getting disabled.
Can you tell me why this is happening? For your reference I'm putting
below the code which will display the data in a Colorbox pop up.
{if $subject_topic_questions}
{foreach from=$subject_topic_questions item=subject_topic_data}
<div class="hidden">
<div id="topics_{$subject_topic_data.subject_id}"
class="c-popup">
<h2 class="c-popup-header">Select Topics</h2>
<div class="c-content">
<input type="hidden"
name="subject_names[{$subject_topic_data.subject_id}]"
id="subject_names"
value="{$subject_topic_data.subject_name}">
<h2 class=""> {$subject_topic_data.subject_name}</h2>
<div class="c-tbl-wrap">
<table width="100%" cellspacing="0"
cellpadding="0" border="0" class="c-tbl">
<tbody>
<tr>
<td>
<p class="custom-form">
<input class="custom-check"
type="checkbox" name="" id="">
<label class="blue">Select All</label>
</p>
</td>
{foreach from=$difficulty_levels item=diff_levels
key=dkey}
<input type="hidden"
name="diff_levels[{$dkey}]"
value="{$diff_levels}">
<td width="22%"
align="center"><strong>{$diff_levels}</strong></td>
{/foreach}
</tr>
{foreach from=$subject_topic_data.topics
item=topic_diff_level_data}
<input type="hidden"
name="subject_{$subject_topic_data.subject_id}_topics[]"
value="{$topic_diff_level_data.topic_id}">
<tr>
<td valign="middle">
<p class="custom-form">
<input type="checkbox"
class="custom-check"
name="{$sheet_type}_topics_{$subject_topic_data.subject_id}[]"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}"
value="{$topic_diff_level_data.topic_id}"
onChange="enable_topic_ques('{$sheet_type}',
'{$subject_topic_data.subject_id}',
'{$topic_diff_level_data.topic_id}');
return false;">
<label>{$topic_diff_level_data.topic_name}</label>
<!-- <input type="hidden"
name="topic_names[{$topic_diff_level_data.topic_id}]"
value="{$topic_diff_level_data.topic_name}">
-->
</p>
</td>
{foreach
from=$topic_diff_level_data.difficulty_level
item=diff_level key=key_diff_lvl}
<td valign="middle">
{if $site_id=='ENTPRM'}<em>Total
{$diff_level.question_count}</em>{/if}
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini"
value="{$diff_level.added_no_questions}"
disabled="disabled">
<input type="hidden"
name="{$sheet_type}_available_questions_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
value="{$diff_level.question_count}">
</td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>
</div>
<p class="center"><a href="#" class="c-btn
fnClosePopup">Done</a> <a href="#"class="c-btn
c-gray-btn fnClosePopup">Cancel</a></p>
</div>
</div>
</div>
{/foreach}
{/if}
The main code you need to consider is as below from the above code:
<input type="text"
name="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
id="{$sheet_type}_{$subject_topic_data.subject_id}_{$topic_diff_level_data.topic_id}_{$key_diff_lvl}"
maxlength="3" class="mini" value="{$diff_level.added_no_questions}"
disabled="disabled">
Can you tell me how the disabled="disabled" attribute gets vanishes after
page load and if there is any way to apply to it, please tell me. Thanks
in advance.
Wednesday, 18 September 2013
Display Image In dynamically ImageViews From Gallery
Display Image In dynamically ImageViews From Gallery
Once See My Problem,Actually I want Show ImageView as below atteched image
like that ,after by clicking button to add imagview dynamically,clicking
image display image from gallary,
![enter image description here][1] Thanks,
Sorry For My poor English...
Once See My Problem,Actually I want Show ImageView as below atteched image
like that ,after by clicking button to add imagview dynamically,clicking
image display image from gallary,
![enter image description here][1] Thanks,
Sorry For My poor English...
allocating an object of abstract class type
allocating an object of abstract class type
im trying to incorporate a CCTable view in my cocos2d-x app. i have
followed the source code from the testcpp and i am still getting this
error and in not 100% sure why
"allocating an object of abstract class type 'GameList'"
here is my source code
GameList.h
#ifndef __Squares__GameList__
#define __Squares__GameList__
#include "cocos2d.h"
#include "cocos-ext.h"
#include "GameListScene.h"
#include "GameManager.h"
using namespace cocos2d;
class GameList : public CCLayer, public extension::CCTableViewDataSource,
public extension::CCTableViewDelegate
{
public:
virtual bool init();
CREATE_FUNC(GameList);
~GameList(void);
CCLabelTTF* titleLabel;
CCLabelTTF* loginLabel;
CCLabelTTF* passwordLabel;
virtual void tableCellTouched(extension::CCTableView* table,
extension::CCTableViewCell* cell);
virtual CCSize tableCellSizeForIndex(extension::CCTableView *table,
unsigned int idx);
virtual unsigned int numberOfCellsInTableView(extension::CCTableView
*table);
};
im trying to incorporate a CCTable view in my cocos2d-x app. i have
followed the source code from the testcpp and i am still getting this
error and in not 100% sure why
"allocating an object of abstract class type 'GameList'"
here is my source code
GameList.h
#ifndef __Squares__GameList__
#define __Squares__GameList__
#include "cocos2d.h"
#include "cocos-ext.h"
#include "GameListScene.h"
#include "GameManager.h"
using namespace cocos2d;
class GameList : public CCLayer, public extension::CCTableViewDataSource,
public extension::CCTableViewDelegate
{
public:
virtual bool init();
CREATE_FUNC(GameList);
~GameList(void);
CCLabelTTF* titleLabel;
CCLabelTTF* loginLabel;
CCLabelTTF* passwordLabel;
virtual void tableCellTouched(extension::CCTableView* table,
extension::CCTableViewCell* cell);
virtual CCSize tableCellSizeForIndex(extension::CCTableView *table,
unsigned int idx);
virtual unsigned int numberOfCellsInTableView(extension::CCTableView
*table);
};
Fortran: Integer too big for its kind
Fortran: Integer too big for its kind
I am setting an integer to a value less than its maximum, but receiving an
error that it is too big for it's kind. Why is this? Here is a sample
program.
program max_int
integer, parameter :: i32 = selected_int_kind(32)
integer(kind = i32) :: my_int
!The largest integer of this kind
print*, huge(my_int)
!This works
my_int = 100000
!This doesn't, and gives an error.
!my_int = 1000000000000
print*, my_int
end program
I am setting an integer to a value less than its maximum, but receiving an
error that it is too big for it's kind. Why is this? Here is a sample
program.
program max_int
integer, parameter :: i32 = selected_int_kind(32)
integer(kind = i32) :: my_int
!The largest integer of this kind
print*, huge(my_int)
!This works
my_int = 100000
!This doesn't, and gives an error.
!my_int = 1000000000000
print*, my_int
end program
What is a more general way of creating an arraylist in C# like the one in the example?
What is a more general way of creating an arraylist in C# like the one in
the example?
Objective: Achieve a more general way of creating an arraylist.
Issue: I have to create multiple arraylists, each matched to a unique
structure for the purpose of comparing and updating a table in Sql
database. In the spirit of DRY I am trying to find a better way of
creating each array. The code I am using is as follows
Sample Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
public static void Users()
{
String sql = "";
try
{
conn.Open();
sql = "SELECT" +
"database.dbo.table1.username," +
"database.dbo.table1.status" +
"FROM" +
"database.dbo.table1";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
//structure below
User structure_A = new User();
structure_A.username = dr.GetValue(0).ToString();
structure_A.status = dr.GetValue(1).ToString();
//added to arraylist
arraylist_A.Add(structure_A);
}
dr.Close();
conn.Close();
}
Note: More information can be provided as requested. Thank you in advance
for any insight
the example?
Objective: Achieve a more general way of creating an arraylist.
Issue: I have to create multiple arraylists, each matched to a unique
structure for the purpose of comparing and updating a table in Sql
database. In the spirit of DRY I am trying to find a better way of
creating each array. The code I am using is as follows
Sample Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
public static void Users()
{
String sql = "";
try
{
conn.Open();
sql = "SELECT" +
"database.dbo.table1.username," +
"database.dbo.table1.status" +
"FROM" +
"database.dbo.table1";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
//structure below
User structure_A = new User();
structure_A.username = dr.GetValue(0).ToString();
structure_A.status = dr.GetValue(1).ToString();
//added to arraylist
arraylist_A.Add(structure_A);
}
dr.Close();
conn.Close();
}
Note: More information can be provided as requested. Thank you in advance
for any insight
Trying to iterate in a item cause: "Uncaught TypeError: Cannot read property 'length' of undefined"
Trying to iterate in a item cause: "Uncaught TypeError: Cannot read
property 'length' of undefined"
I'm trying to iterate through a element using this code:
$.each(element, function(index, item) {
...
});
I check element type by executing this command $.type(element) in Chrome
console and I got "object" as output. I check also what has element inside
using this command element and got this as output:
[<input type=​"text" name=​"input_color_5[]​"
class=​"field_color" data-selector=​"color"
data-id=​"color_5" placeholder=​"Color">​]
Also I tried all this command from console:
element.val() -> return ""
element.attr('data-selector') -> return "color"
element.attr('data-id') -> return "color_5"
If I use instead this other code:
element.each(function(index, item) {
...
});
Then the error turn on:
Uncaught TypeError: Cannot call method 'each' of undefined
This is how I construct element object:
function getDivId() {
var inputValues = [];
inputValues.push($('#choices_picker input[type="text"]'));
return inputValues;
}
And I call later in this way:
$('#choices_picker').on("click", "#create-variation", function(e) {
var parent_id = $(this).closest("section").attr("id");
var element = getDivId(parent_id);
$('#variations_holder').show();
$('#variations_holder').html("");
html = "";
iterateChoices("", element[0], element.slice(1), 0);
$('#variations_holder').append(html);
});
And finally this is the function iterateChoices():
function iterateChoices(row, element, choices, counter) {
if ($.isArray(choices)) {
$.each(element, function(index, item) {
if (counter === 0) {
row = '<label>UPC:</label> <input style="display:
inline-block" type="text" value="" name="pupc[]" />';
row += '<label>Precio:</label> <input style="display:
inline-block" type="text" value="" name="pprice[]" />';
row += '<label>Cantidad:</label><input type="text"
style="display: inline-block" value="" name="pqty[]" />';
}
if (choices.length > 0) {
iterateChoices(row + '<input disabled="disabled" value="'
+ item.value + '"></div>', choices[0], choices.slice(1),
counter + 1);
}
});
} else {
html_temp = "";
element.each(function(index, item) {
html_temp += row + '<input value="' + item.value + '"
disabled="disabled"><br>';
});
html += html_temp;
}
}
Then I ask myself, isn't element a object since I got the error? What is
wrong or what I'm doing wrong?
property 'length' of undefined"
I'm trying to iterate through a element using this code:
$.each(element, function(index, item) {
...
});
I check element type by executing this command $.type(element) in Chrome
console and I got "object" as output. I check also what has element inside
using this command element and got this as output:
[<input type=​"text" name=​"input_color_5[]​"
class=​"field_color" data-selector=​"color"
data-id=​"color_5" placeholder=​"Color">​]
Also I tried all this command from console:
element.val() -> return ""
element.attr('data-selector') -> return "color"
element.attr('data-id') -> return "color_5"
If I use instead this other code:
element.each(function(index, item) {
...
});
Then the error turn on:
Uncaught TypeError: Cannot call method 'each' of undefined
This is how I construct element object:
function getDivId() {
var inputValues = [];
inputValues.push($('#choices_picker input[type="text"]'));
return inputValues;
}
And I call later in this way:
$('#choices_picker').on("click", "#create-variation", function(e) {
var parent_id = $(this).closest("section").attr("id");
var element = getDivId(parent_id);
$('#variations_holder').show();
$('#variations_holder').html("");
html = "";
iterateChoices("", element[0], element.slice(1), 0);
$('#variations_holder').append(html);
});
And finally this is the function iterateChoices():
function iterateChoices(row, element, choices, counter) {
if ($.isArray(choices)) {
$.each(element, function(index, item) {
if (counter === 0) {
row = '<label>UPC:</label> <input style="display:
inline-block" type="text" value="" name="pupc[]" />';
row += '<label>Precio:</label> <input style="display:
inline-block" type="text" value="" name="pprice[]" />';
row += '<label>Cantidad:</label><input type="text"
style="display: inline-block" value="" name="pqty[]" />';
}
if (choices.length > 0) {
iterateChoices(row + '<input disabled="disabled" value="'
+ item.value + '"></div>', choices[0], choices.slice(1),
counter + 1);
}
});
} else {
html_temp = "";
element.each(function(index, item) {
html_temp += row + '<input value="' + item.value + '"
disabled="disabled"><br>';
});
html += html_temp;
}
}
Then I ask myself, isn't element a object since I got the error? What is
wrong or what I'm doing wrong?
How can I skip path resolution when creating a new VS project?
How can I skip path resolution when creating a new VS project?
I've created a custom MVC VS project template for my company. Within the
csproj file, I reference the "_references.js" file of a different project
a couple of levels higher than my current project. The way I have added
this file in the template is as follows:
<ItemGroup>
<Content Include="..\..\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
However, this ends up rendering like this when the project is created:
<ItemGroup>
<Content
Include="..\..\..\..\..\..\..\Users\MyUser\AppData\Local\Temp\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
It looks like the process of creating the project is resolving the path in
relation to the location of where the template is being used to build the
project.
Is there someway to force my path? I'd like this path to remain constant
when the project is rendered.
Thanks!
I've created a custom MVC VS project template for my company. Within the
csproj file, I reference the "_references.js" file of a different project
a couple of levels higher than my current project. The way I have added
this file in the template is as follows:
<ItemGroup>
<Content Include="..\..\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
However, this ends up rendering like this when the project is created:
<ItemGroup>
<Content
Include="..\..\..\..\..\..\..\Users\MyUser\AppData\Local\Temp\MyCompany\Scripts\_references.js">
<Link>Scripts\_references.js</Link>
</Content>
...
</ItemGroup>
It looks like the process of creating the project is resolving the path in
relation to the location of where the template is being used to build the
project.
Is there someway to force my path? I'd like this path to remain constant
when the project is rendered.
Thanks!
Chef: why can't I subscribe to a directory :create action?
Chef: why can't I subscribe to a directory :create action?
I have created the following recipe block which should run at the point
that the /etc/httpd/ssl directory is created:
ruby_block "Copy SSL certificates" do
block do
certificate_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_filename']}"
key_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_key_filename']}"
chain_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_chain_filename']}"
if File.exists?(certificate_file) && File.exists?(key_file)
FileUtils.cp(certificate_file, "#{node['apache']['dir']}/ssl")
FileUtils.cp(key_file, "#{node['apache']['dir']}/ssl")
end
if File.exists?(chain_file)
FileUtils.cp(chain_file, "#{node['apache']['dir']}/ssl")
end
end
action :nothing
subscribes :create, resources(:directory => "/etc/httpd/ssl")
end
(This is directly modelled off an opscode example - under "Stash a file in
a data bag")
In the Chef output, I can see my recipe file being loaded:
[2013-09-18T13:19:45+00:00] DEBUG: Loading Recipe
chef-magento::copy_ssl_certificates via include_recipe
and, lower down, I can see the directory being created:
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/ssl]
action create (apache2::default line 138)
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] created
directory /etc/httpd/ssl
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] owner changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] group changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] mode changed
to 755
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/conf.d]
action create (apache2::default line 145)
but at no point does it run my code.
What am I doing wrong?
I have created the following recipe block which should run at the point
that the /etc/httpd/ssl directory is created:
ruby_block "Copy SSL certificates" do
block do
certificate_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_filename']}"
key_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_key_filename']}"
chain_file =
"#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_chain_filename']}"
if File.exists?(certificate_file) && File.exists?(key_file)
FileUtils.cp(certificate_file, "#{node['apache']['dir']}/ssl")
FileUtils.cp(key_file, "#{node['apache']['dir']}/ssl")
end
if File.exists?(chain_file)
FileUtils.cp(chain_file, "#{node['apache']['dir']}/ssl")
end
end
action :nothing
subscribes :create, resources(:directory => "/etc/httpd/ssl")
end
(This is directly modelled off an opscode example - under "Stash a file in
a data bag")
In the Chef output, I can see my recipe file being loaded:
[2013-09-18T13:19:45+00:00] DEBUG: Loading Recipe
chef-magento::copy_ssl_certificates via include_recipe
and, lower down, I can see the directory being created:
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/ssl]
action create (apache2::default line 138)
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] created
directory /etc/httpd/ssl
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] owner changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] group changed
to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] mode changed
to 755
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/conf.d]
action create (apache2::default line 145)
but at no point does it run my code.
What am I doing wrong?
Revision Control - Ruby on Rails
Revision Control - Ruby on Rails
I have this application i'm working on and it works just fine. I am using
paperclip for image upload. User's can upload logos after which an admin
can accept them or ask them for changes after which they will upload an
updated version after they make ammends.
Right now, when you edit with paperclip (upload a new image) it deletes
the old one. I want like to keep a revision of how the logos have changed
over time. The old images should be accessible in some kind of history.
Are there any tutorials on how to do this, or how can I go about
implementing this functionality?
Any help will be very much appreciated. Thanks!!!!!
I have this application i'm working on and it works just fine. I am using
paperclip for image upload. User's can upload logos after which an admin
can accept them or ask them for changes after which they will upload an
updated version after they make ammends.
Right now, when you edit with paperclip (upload a new image) it deletes
the old one. I want like to keep a revision of how the logos have changed
over time. The old images should be accessible in some kind of history.
Are there any tutorials on how to do this, or how can I go about
implementing this functionality?
Any help will be very much appreciated. Thanks!!!!!
Tuesday, 17 September 2013
How to Java Regex to match everything but specified pattern
How to Java Regex to match everything but specified pattern
I am trying to match everything but garbage values in the entire
string.The pattern I am trying to use is:
^.*(?!\w|\s|-|\.|[@:,]).*$
I have been testing the pattern on regexPlanet and this seems to be
matching the entire string.The input string I was using was:
Vamsi///#k03@g!!!l.com 123**5
How can I get it to only match everything but the pattern,I would like to
replace any string that matches with an empty space or a special charecter
of my choice.
I am trying to match everything but garbage values in the entire
string.The pattern I am trying to use is:
^.*(?!\w|\s|-|\.|[@:,]).*$
I have been testing the pattern on regexPlanet and this seems to be
matching the entire string.The input string I was using was:
Vamsi///#k03@g!!!l.com 123**5
How can I get it to only match everything but the pattern,I would like to
replace any string that matches with an empty space or a special charecter
of my choice.
Saving images from website to folder using curl php
Saving images from website to folder using curl php
I am able to save images from a website using curl like so:
//$fullpath = "/images/".basename($img);
$fullpath = basename($img);
$ch = curl_init($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$rawData = curl_exec($ch);
curl_close($ch);
if(file_exists($fullpath)) {
unlink($fullpath);
}
$fp = fopen($fullpath, 'w+');
fwrite($fp, $rawData);
fclose($fp);
However, this will only save the image on the same folder in which I have
the php file that executes the save function is in. I'd like to save the
images to a specific folder. I've tried using $fullpath =
"/images/".basename($img); (the commented out first line of my function)
but this results to an error:
failed to open stream: No such file or directory
So my question is, how can I save the file on a specific folder in my
project? Another question I have is, how can I change the filename of the
image I save on the my folder? For example, I'd like to add the prefix
siteimg_ to the image's filename. How do I implement this?
I am able to save images from a website using curl like so:
//$fullpath = "/images/".basename($img);
$fullpath = basename($img);
$ch = curl_init($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$rawData = curl_exec($ch);
curl_close($ch);
if(file_exists($fullpath)) {
unlink($fullpath);
}
$fp = fopen($fullpath, 'w+');
fwrite($fp, $rawData);
fclose($fp);
However, this will only save the image on the same folder in which I have
the php file that executes the save function is in. I'd like to save the
images to a specific folder. I've tried using $fullpath =
"/images/".basename($img); (the commented out first line of my function)
but this results to an error:
failed to open stream: No such file or directory
So my question is, how can I save the file on a specific folder in my
project? Another question I have is, how can I change the filename of the
image I save on the my folder? For example, I'd like to add the prefix
siteimg_ to the image's filename. How do I implement this?
How can I disable input field spaces with MooTools?
How can I disable input field spaces with MooTools?
I can't find this anywhere, we need to disable the space bar (spaces) in a
input field of our form using MooTools 1.2
I have a solution for jQuery which doesn't work, however we have our site
based completely on our framework of choice.
Thank you for your help!!
<form action="signup.php" method="POST">
<input id='username' name='signup_username' type='text'
class='home_signin_field' maxlength='50' size='22'
onclick="this.value='';" onfocus="this.value='';"
onblur="this.value=!this.value?'Your Name':this.value;" value="Your Name">
</form>
I can't find this anywhere, we need to disable the space bar (spaces) in a
input field of our form using MooTools 1.2
I have a solution for jQuery which doesn't work, however we have our site
based completely on our framework of choice.
Thank you for your help!!
<form action="signup.php" method="POST">
<input id='username' name='signup_username' type='text'
class='home_signin_field' maxlength='50' size='22'
onclick="this.value='';" onfocus="this.value='';"
onblur="this.value=!this.value?'Your Name':this.value;" value="Your Name">
</form>
Detect mouseover on element bottom margin
Detect mouseover on element bottom margin
Is it possible with plain JavaScript or jQuery to detect a mouseover on an
element bottom margin, ie when the mouse is over the element margin but
not on the element contain itself?
It seems it's possible because the Medium editor can display a link (a
"plus" sign) when the mouse is over the bottom margin of paragraph
elements, but not when the mouse is over the paragraph text. I have no
idea how they achieve that. Here is how it works in Medium:
http://d.pr/i/njS+
Is it possible with plain JavaScript or jQuery to detect a mouseover on an
element bottom margin, ie when the mouse is over the element margin but
not on the element contain itself?
It seems it's possible because the Medium editor can display a link (a
"plus" sign) when the mouse is over the bottom margin of paragraph
elements, but not when the mouse is over the paragraph text. I have no
idea how they achieve that. Here is how it works in Medium:
http://d.pr/i/njS+
Google Map Heading Marker or Indicator
Google Map Heading Marker or Indicator
The "Google Maps" app in Jellybean has an indicator which adjusts based on
the way you're facing. I am interested in implementing a similar indicator
but for multiple indicators.
Does anyone have an idea on how they implemented their heading indicator
(note it maintains its heading even when the map is rotated). I attempted
my own approach using markers, then I realized that markers will not
rotate with the map (kind of an oh duh moment after a few hours of
labor...)
So as of right now I see two solutions:
Capture map rotation and transfer it to the marker
Draw over the map using OpenGL
Could anyone offer any advice before I start down another rabbit hole?
Thanks!
The "Google Maps" app in Jellybean has an indicator which adjusts based on
the way you're facing. I am interested in implementing a similar indicator
but for multiple indicators.
Does anyone have an idea on how they implemented their heading indicator
(note it maintains its heading even when the map is rotated). I attempted
my own approach using markers, then I realized that markers will not
rotate with the map (kind of an oh duh moment after a few hours of
labor...)
So as of right now I see two solutions:
Capture map rotation and transfer it to the marker
Draw over the map using OpenGL
Could anyone offer any advice before I start down another rabbit hole?
Thanks!
Sunday, 15 September 2013
How do I install gimp on Android
How do I install gimp on Android
I am trying to install GIMP on android.
because I am trying to do some good art on my android tablet. I have
autodesk Sketch Book and I am Really good doing art on that. I was also
trying gfxtablet and gimp on linux.
Much THANKS.
I am trying to install GIMP on android.
because I am trying to do some good art on my android tablet. I have
autodesk Sketch Book and I am Really good doing art on that. I was also
trying gfxtablet and gimp on linux.
Much THANKS.
jsfiddle same codes display different results on html
jsfiddle same codes display different results on html
I put http://jsfiddle.net/48Hpa/19/ same codes to HTML, but I get
different results
....................................................................................................................................................................
why is that?
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet"
href="http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css"
/>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$(function () {
$("#slider1").slider({
range: "min",
value: 36,
min: 12,
max: 36,
slide: function (event, ui) {
$(".amount1").val(ui.value);
writesum();
}
});
$(".amount1").val($("#slider1").slider("value"));
});
$(function () {
$("#slider2").slider({
range: "min",
value: 50000,
min: 1,
max: 50000,
slide: function (event, ui) {
$(".amount2").val(ui.value);
writesum();
}
});
$(".amount2").val($("#slider2").slider("value"));
});
function writesum() {
var months = $('.amount1').val();
var credits = $('.amount2').val();
var payment = parseFloat(Number(credits) / Number(months))
var rounded = payment.toFixed(2);
$('.amount3').val(rounded);
}
});
</script>
</head>
<body>
<input type="text" class="amount1" />
<div class="container">
<div id="slider1"></div>
</div>
<input type="text" class="amount2" />
<div class="container">
<div id="slider2"></div>
</div>
<div class="sonuccontainer">
<div class="bilgilendirme">aylýk ödeme miktarýnýz</div>
<input type="text" class="amount3" />
</div>
</body>
</html>
I put http://jsfiddle.net/48Hpa/19/ same codes to HTML, but I get
different results
....................................................................................................................................................................
why is that?
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet"
href="http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css"
/>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$(function () {
$("#slider1").slider({
range: "min",
value: 36,
min: 12,
max: 36,
slide: function (event, ui) {
$(".amount1").val(ui.value);
writesum();
}
});
$(".amount1").val($("#slider1").slider("value"));
});
$(function () {
$("#slider2").slider({
range: "min",
value: 50000,
min: 1,
max: 50000,
slide: function (event, ui) {
$(".amount2").val(ui.value);
writesum();
}
});
$(".amount2").val($("#slider2").slider("value"));
});
function writesum() {
var months = $('.amount1').val();
var credits = $('.amount2').val();
var payment = parseFloat(Number(credits) / Number(months))
var rounded = payment.toFixed(2);
$('.amount3').val(rounded);
}
});
</script>
</head>
<body>
<input type="text" class="amount1" />
<div class="container">
<div id="slider1"></div>
</div>
<input type="text" class="amount2" />
<div class="container">
<div id="slider2"></div>
</div>
<div class="sonuccontainer">
<div class="bilgilendirme">aylýk ödeme miktarýnýz</div>
<input type="text" class="amount3" />
</div>
</body>
</html>
How to generate a labelled dendogram using agnes?
How to generate a labelled dendogram using agnes?
Using the code from :
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
Here is how to generate a dendogram :
# import data
x <- read.table("data.txt")
# run AGNES
ag <- agnes (x, false, metric="euclidean", false, method ="single")
# print components of ag
print(ag)
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
I'm receiving an error on
ag <- agnes (x, false, metric="euclidean", false, method ="single")
The error is :
Error in agnes(x, false, metric = "euclidean", false, method = "single") :
object 'false' not found
This implementation of agnes works but its generating numbered labels for
the dendogram :
ag <- agnes (data, metric="euclidean")
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
The dendogram :
The dendogram generated from
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
includes labels :
Here is the data file :
,ba,fi,mi,vo,rm,to
ba,0,662,877,255,412,996
fi,662,0,295,468,268,400
mi,877,295,0,754,564,138
vo,255,468,754,0,219,869
rm,412,268,564,219,0,669
to,996,400,138,869,669,0
How can generate a labelled hierarchical cluster based on above data which
is same as labelled dendogram above ?
Using the code from :
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
Here is how to generate a dendogram :
# import data
x <- read.table("data.txt")
# run AGNES
ag <- agnes (x, false, metric="euclidean", false, method ="single")
# print components of ag
print(ag)
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
I'm receiving an error on
ag <- agnes (x, false, metric="euclidean", false, method ="single")
The error is :
Error in agnes(x, false, metric = "euclidean", false, method = "single") :
object 'false' not found
This implementation of agnes works but its generating numbered labels for
the dendogram :
ag <- agnes (data, metric="euclidean")
# plot clusters
plot(ag, ask = FALSE, which.plots = NULL)
The dendogram :
The dendogram generated from
http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Hierarchical_Clustering
includes labels :
Here is the data file :
,ba,fi,mi,vo,rm,to
ba,0,662,877,255,412,996
fi,662,0,295,468,268,400
mi,877,295,0,754,564,138
vo,255,468,754,0,219,869
rm,412,268,564,219,0,669
to,996,400,138,869,669,0
How can generate a labelled hierarchical cluster based on above data which
is same as labelled dendogram above ?
Parse error: syntax error, unexpected T_VARIABLE in bindValue
Parse error: syntax error, unexpected T_VARIABLE in bindValue
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = $_POST['content'];
if (empty($title) or empty($content)) {
$error = 'All fields are required!';
} else {
$query = $pdo->prepare("INSERT INTO articles (atricle_title,
atricle_text, atricle_timestamp) VALUES (?, ?, ?)")
$query->bindValue(1, $title); //error is here
$query->bindValue(2, $content);
$query->bindValue(3, time());
$query->execute();
header(Location: index.php);
}
Someone knows what's the problem here?. The code itself is more then that,
but this is to only relevent part.
Thanks.
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = $_POST['content'];
if (empty($title) or empty($content)) {
$error = 'All fields are required!';
} else {
$query = $pdo->prepare("INSERT INTO articles (atricle_title,
atricle_text, atricle_timestamp) VALUES (?, ?, ?)")
$query->bindValue(1, $title); //error is here
$query->bindValue(2, $content);
$query->bindValue(3, time());
$query->execute();
header(Location: index.php);
}
Someone knows what's the problem here?. The code itself is more then that,
but this is to only relevent part.
Thanks.
Struggling with simple node.js code
Struggling with simple node.js code
I really can't figure out what I've done wrong. I've spent about half an
hour looking at this code and re-reading code that essentially does the
same thing and works. The 'data' event and corresponding callback is never
triggered.
var http = require("http");
http.createServer(function(request, response){
response.writeHead(200);
console.log('Executing');
request.on('data', function(chunk){
console.log('data being read');
console.log(chunk.toString());
});
request.on('end', function(){
console.log('done');
response.end();
});
}).listen(8080);
Please help
I really can't figure out what I've done wrong. I've spent about half an
hour looking at this code and re-reading code that essentially does the
same thing and works. The 'data' event and corresponding callback is never
triggered.
var http = require("http");
http.createServer(function(request, response){
response.writeHead(200);
console.log('Executing');
request.on('data', function(chunk){
console.log('data being read');
console.log(chunk.toString());
});
request.on('end', function(){
console.log('done');
response.end();
});
}).listen(8080);
Please help
Parents Selector in CSS?
Parents Selector in CSS?
For example HTML :
<div id="css">
<a href="/forum"></a>
</div>
How can I choose the parent selector of a href ? I have tried :
#css! > a[href*="/forum"]
But not successful . Thanks for your helping
For example HTML :
<div id="css">
<a href="/forum"></a>
</div>
How can I choose the parent selector of a href ? I have tried :
#css! > a[href*="/forum"]
But not successful . Thanks for your helping
PHP: Sessions never expire
PHP: Sessions never expire
Last night I logged in and the following morning I was still logged in,
even if I quit my browser. I want the session to expire after a few hours
and I thought that it would work with "session.gc_maxlifetime" set to
"1440" and "session.cache_expire" set to "180"
Here is what I could find from PHP.ini
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
session.auto_start Off
session.bug_compat_42 Off
session.bug_compat_warn Off
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_httponly Off
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 1000
session.gc_maxlifetime 1440
session.gc_probability 0
session.hash_bits_per_character 5
session.hash_function 0
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path /var/lib/php5
session.serialize_handler php
session.use_cookies On
session.use_only_cookies On
session.use_trans_sid 0
On our old server we used the same settings and the sessions worked. The
only difference from the old one is the "session.save_handler" that is set
to "memcache" on the old server. Also "session.save_path" is different.
Last night I logged in and the following morning I was still logged in,
even if I quit my browser. I want the session to expire after a few hours
and I thought that it would work with "session.gc_maxlifetime" set to
"1440" and "session.cache_expire" set to "180"
Here is what I could find from PHP.ini
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
session.auto_start Off
session.bug_compat_42 Off
session.bug_compat_warn Off
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_httponly Off
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 1000
session.gc_maxlifetime 1440
session.gc_probability 0
session.hash_bits_per_character 5
session.hash_function 0
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path /var/lib/php5
session.serialize_handler php
session.use_cookies On
session.use_only_cookies On
session.use_trans_sid 0
On our old server we used the same settings and the sessions worked. The
only difference from the old one is the "session.save_handler" that is set
to "memcache" on the old server. Also "session.save_path" is different.
Saturday, 14 September 2013
Disable direct access to certain files (include)
Disable direct access to certain files (include)
I'm triyng to blobk access to certain files. I have on my server many
files like this
filename_sql.php
Basically i need to disallow user to access directly to sql.php files:
http://url.com/filename_sql.php <<<
I have created an htaccess with this code, but i can access files direcly
calling url. What do I wrong?
<Files ~ "\.sql(.php)?$">
Order allow,deny
Deny from all
</Files>
Thanks all.
I'm triyng to blobk access to certain files. I have on my server many
files like this
filename_sql.php
Basically i need to disallow user to access directly to sql.php files:
http://url.com/filename_sql.php <<<
I have created an htaccess with this code, but i can access files direcly
calling url. What do I wrong?
<Files ~ "\.sql(.php)?$">
Order allow,deny
Deny from all
</Files>
Thanks all.
Django Template - iterating through nested dictionary - too many examples
Django Template - iterating through nested dictionary - too many examples
I have a call to an external data source that successfully returns a
dictionary in this format. There can be any number of entries:
{
'0090000': {'status': 'some status', 'modified_date':
'2013-08-09T14:23:32Z', 'modified_by': 'John Doe', 'severity': '3
(Normal)', 'created_by': 'Dan Smith', 'summary': "some status",
'created_date': '2013-07-18T21:10:36Z'},
'0060000': {'status': 'some status', 'modified_date':
'2013-06-24T03:19:01Z', 'modified_by': 'Jay Johnson', 'severity': '4
(Low)', 'created_by': 'Tony Thompson', 'summary': "some other status",
'created_date': '2012-05-03T17:45:19Z'}...
}
I'm pulling this data end using some information gathered in a form. I've
read a ton of docs and examples of how to iterate through this and present
the data in a template but I can't quite make it work.
My view is as follows:
def agenda_detail(request, agenda_id):
#get the meeting data
a_data = get_object_or_404(meetingEvent, pk=agenda_id)
#get the DEE data for the VAT fieldset
account_id = a_data.account_number.pk
#get the stored session user/pass
username = request.session['username']
password = request.session['password']
dee_data = onsiteEngineer.objects.filter(account=account_id)
#now we get the case data from the Portal API
portal_raw = CustomerInformation()
customer_data = portal_raw.getOpenCaseInfo(account_id,username,password)
return render_to_response('agendas/detail.html',{'a_data':a_data,
'dee_data': dee_data, 'customer_data': customer_data.iteritems()},
context_instance=RequestContext(request))
My template code dealing with this is (I don't care about the html
formatting right now, i just want to see the data on the screen:
{% for key, value in customer_data.items %}
<p>{{ key }}</p>
{% for info in value %}
{{ value }}
{% endfor %}
{% endfor %}
It's showing no data. I've tried multiple combinations (using .items,
using iteritems, etc.) but I can't quite get it to work.
All advice appreciated.
I have a call to an external data source that successfully returns a
dictionary in this format. There can be any number of entries:
{
'0090000': {'status': 'some status', 'modified_date':
'2013-08-09T14:23:32Z', 'modified_by': 'John Doe', 'severity': '3
(Normal)', 'created_by': 'Dan Smith', 'summary': "some status",
'created_date': '2013-07-18T21:10:36Z'},
'0060000': {'status': 'some status', 'modified_date':
'2013-06-24T03:19:01Z', 'modified_by': 'Jay Johnson', 'severity': '4
(Low)', 'created_by': 'Tony Thompson', 'summary': "some other status",
'created_date': '2012-05-03T17:45:19Z'}...
}
I'm pulling this data end using some information gathered in a form. I've
read a ton of docs and examples of how to iterate through this and present
the data in a template but I can't quite make it work.
My view is as follows:
def agenda_detail(request, agenda_id):
#get the meeting data
a_data = get_object_or_404(meetingEvent, pk=agenda_id)
#get the DEE data for the VAT fieldset
account_id = a_data.account_number.pk
#get the stored session user/pass
username = request.session['username']
password = request.session['password']
dee_data = onsiteEngineer.objects.filter(account=account_id)
#now we get the case data from the Portal API
portal_raw = CustomerInformation()
customer_data = portal_raw.getOpenCaseInfo(account_id,username,password)
return render_to_response('agendas/detail.html',{'a_data':a_data,
'dee_data': dee_data, 'customer_data': customer_data.iteritems()},
context_instance=RequestContext(request))
My template code dealing with this is (I don't care about the html
formatting right now, i just want to see the data on the screen:
{% for key, value in customer_data.items %}
<p>{{ key }}</p>
{% for info in value %}
{{ value }}
{% endfor %}
{% endfor %}
It's showing no data. I've tried multiple combinations (using .items,
using iteritems, etc.) but I can't quite get it to work.
All advice appreciated.
Subscribe to:
Comments (Atom)