Thursday, 3 October 2013

What would be the best approach to implement a multi-select combo in SWT/JFace?

What would be the best approach to implement a multi-select combo in
SWT/JFace?

I need to implement a multi-select combobox using SWT/JFace, What would be
the best approach?

Wednesday, 2 October 2013

Getting the height of the image to set modal window size

Getting the height of the image to set modal window size

I am creating a photo gallery with thumbnails and loads the resized image
into the modal window.
The problem is I want to get the height and width of the image to set the
height of the modal window, however the height is not being set on the
modal window or my container for my image.
The src of the image is not in my markup originally but I add it to the
markup by appending it on the fly.
Original Thumbnail Image
<img src="\images\picture1.jpg" height="150" width="150" id="thumbnail">
Jquery code:
var tImageID = $(this).find('img').attr( 'id', 'thumbnail' );
var fullURL = $(tImageID).attr('src');
var dFigure = $('#dialog-media figure .media');
// fullSrcURL = "\images\picture_resized.jpg"
var fullSrcURL = fullURL.replace(".jpg", "_resized.jpg");
// Add html to the div tag
$(dFigure).append('<img id="resized-pic" src="' + fullSrcURL + '"
alt="' + $(tImage).attr('alt') + '" />');
var objHeight = $("#resized-pic").height();
var objWidth = $("#resized-pic").width();
// Perform some other code here
// Some more logic
//Set the positioning of the modal window with theses CSS properties
$('.ui-dialog').css('left', '0');
$('.ui-dialog').css('right', '0');
$('.ui-dialog').css('margin', '0 auto');
$('.ui-dialog').css('width', objWidth);
$('.ui-dialog').css('height', ObjHeight);
$('.ui-dialog').css('top', '5%');
The picture loads up, but the objWidth and objHeight show up as zero when
looking at firebug.
I refresh my page, click on the same thumbail and the picture loads up
with the image within the modal and the height of the modal is set
properly.
Is it because the picture hasn't completely loaded and that is why it is
zero? Or is it because it is cached?
Thanks
Cheers

Detect presence of a specific String in Javascript String

Detect presence of a specific String in Javascript String

How can i do to search if a Javascript String contains the following
pattern :
"@someting.temp"
I would like to know if the String contains @ character and then someting
and then ".temp" string.
Thanks

Receive an EnumSet from a spring form checkbox element?

Receive an EnumSet from a spring form checkbox element?

I've seen a few related questions on this topic but none that seem to
exactly match what I'm after.
I have a form where I'd like the user to be able to select a number of
items from a checkbox list (backed by an enum), and to receive that as a
Set. I have the following (using days as an example)
My enum:
public enum Day {
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
}
Sending the enum values to the page in the controller to be displayed as
the options:
model.addAttribute("allDays", Day.values());
Writing the options as checkboxes and mapping to correct form field:
<form:form method="get" modelAttribute="filterForm" commandName="filterForm">
<c:forEach items="${allDays}" var="item">
<form:checkbox path="days" value="${item.ordinal()}"
label="${item.name()}"/>
</c:forEach>
</form:form>
The form object backing the form:
public class FilterForm {
private EnumSet<Day> days;
public EnumSet<Day> getDays() {
return days;
}
public void setDays(EnumSet<Day> days) {
this.days = days;
}
}
This works as far as showing the options correctly, but when I try to
submit, I get an error:
org.springframework.validation.BindException:
org.springframework.validation.BeanPropertyBindingResult: 1 errors Field
error in object 'filterForm' on field 'days': rejected value [0,1]; codes
[typeMismatch.filterForm.days,typeMismatch.days,typeMismatch.java.util.EnumSet,typeMismatch];
arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes
[filterForm.days,days]; arguments []; default message [days]]; default
message [Failed to convert property value of type 'java.lang.String[]' to
required type 'java.util.EnumSet' for property 'days'; nested exception is
org.springframework.core.convert.ConversionFailedException: Failed to
convert from type java.lang.String[] to type java.util.EnumSet for value
'{0, 1}'; nested exception is java.lang.IllegalArgumentException: Could
not instantiate Collection type: java.util.EnumSet]
org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75)
org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
Any idea what the problem is or if there is a better way to achieve this?
Thanks

Tuesday, 1 October 2013

What is the best way to deserialize the Byte Array in C++ which is in Big Endiaan format?

What is the best way to deserialize the Byte Array in C++ which is in Big
Endiaan format?

I am writing Byte Array value into a file using Java with Big Endian Byte
Order format.. Now I need to read that file from C++ program...
That Byte Array which I am writing into a file is made up of three Byte
Arrays as described below-
short employeeId = 32767;
long lastModifiedDate = "1379811105109L";
byte[] attributeValue = os.toByteArray();
I am writing employeeId , lastModifiedDate and attributeValue together
into a single Byte Array and that resulting Byte Array I am writing into a
file and then I will be having my C++ program which will retrieve that
Byte Array data from file and then deserialize it to extract employeeId ,
lastModifiedDate and attributeValue from it.
Below is my Java code which is writing Byte Array value into a file with
Big Endian format and it is working fine...
public class ByteBufferTest {
public static void main(String[] args) {
String text = "Byte Array Test For Big Endian";
byte[] attributeValue = text.getBytes();
long lastModifiedDate = 1289811105109L;
short employeeId = 32767;
int size = 2 + 8 + 4 + attributeValue.length; // short is 2 bytes,
long 8 and int 4
ByteBuffer bbuf = ByteBuffer.allocate(size);
bbuf.order(ByteOrder.BIG_ENDIAN);
bbuf.putShort(employeeId);
bbuf.putLong(lastModifiedDate);
bbuf.putInt(attributeValue.length);
bbuf.put(attributeValue);
bbuf.rewind();
// best approach is copy the internal buffer
byte[] bytesToStore = new byte[size];
bbuf.get(bytesToStore);
writeFile(bytesToStore);
}
/**
* Write the file in Java
* @param byteArray
*/
public static void writeFile(byte[] byteArray) {
try{
File file = new File("bytebuffertest");
FileOutputStream output = new FileOutputStream(file);
IOUtils.write(byteArray, output);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Now I need to retrieve Byte Array from that same file using the below C++
program and deserialize it to extract employeeId , lastModifiedDate and
attributeValue from it. I am not sure what is the best way on the C++
side. Below is the code I have got so far on C++ side-
int main() {
string line;
std::ifstream myfile("bytebuffertest", std::ios::binary);
if (myfile.is_open()) {
uint16_t employeeId;
uint64_t lastModifiedDate;
uint32_t attributeLength;
char buffer[8]; // sized for the biggest read we want to do
// read two bytes (will be in the wrong order)
myfile.read(buffer, 2);
// swap the bytes
std::swap(buffer[0], buffer[1]);
// only now convert bytes to an integer
employeeId = *reinterpret_cast<uint16_t*>(buffer);
cout<< employeeId <<endl;
// read eight bytes (will be in the wrong order)
myfile.read(buffer, 8);
// swap the bytes
std::swap(buffer[0], buffer[7]);
std::swap(buffer[1], buffer[6]);
std::swap(buffer[2], buffer[5]);
std::swap(buffer[3], buffer[4]);
// only now convert bytes to an integer
lastModifiedDate = *reinterpret_cast<uint64_t*>(buffer);
cout<< lastModifiedDate <<endl;
// read 4 bytes (will be in the wrong order)
myfile.read(buffer, 4);
// swap the bytes
std::swap(buffer[0], buffer[3]);
std::swap(buffer[1], buffer[2]);
// only now convert bytes to an integer
attributeLength = *reinterpret_cast<uint32_t*>(buffer);
cout<< attributeLength <<endl;
myfile.read(buffer, attributeLength);
// now I am not sure how should I get the actual attribute value
here?
//close the stream:
myfile.close();
}
else
cout << "Unable to open file";
return 0;
}
Can anybody take a look on C++ code and see what I can do to improve it as
I don't think so it is looking much efficient? Any better way to
deserialize the Byte Array and extract relevant information on the C++
side?
Thanks for the help..

Uncaught SyntaxError: Unexpected identifier Readability.js:108

Uncaught SyntaxError: Unexpected identifier Readability.js:108

I want to investigate the functionality of reader mode in Firefox for
Android. To do that I took Readability.js from Firefox sources and created
a simple HTML file:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<script src="Readability.js"></script>
</body> </html>
If I load the above page in Chrome and open JavaScript Console I see
Uncaught SyntaxError: Unexpected identifier Readability.js:108
If I do the same in Firefox, the result is similar:
SyntaxError: missing ; before statement @ file:///XXX/Readability.js:108
Why does Readability.js work in Firefox for Android and does not when used
as shown above in desktop browsers?

nginx - show different page when ip address is given instead of domain name

nginx - show different page when ip address is given instead of domain name

I have installed on my vps nginx with ISPConfig3. I created a domain
mydomain.com through ispconfig and everything works just fine except two
things.
When i go to the ip address of my vps, my website is shown. I want a
different page ex. /var/www/index.html to be shown
I want to redirect from www.mydomain.com to mydomain.com.
Here is the virtual hosts in sites-enabled:
000-apps.vhost
server {
listen 8081;
server_name _;
root /var/www/apps;
client_max_body_size 20M;
location / {
index index.php index.html;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with
--enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_pass unix:/var/lib/php5-fpm/apps.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~ /\. {
deny all;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD
$request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH
$content_length;
fastcgi_param SCRIPT_FILENAME
$request_filename;
fastcgi_param SCRIPT_NAME
$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT
$document_root;
fastcgi_param SERVER_PROTOCOL
$server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE
nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with
--enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
# To access phpMyAdmin, the default user (like
www-data on Debian/Ubuntu) must be used
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 240;
}
location ~*
^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$
{
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
location /squirrelmail {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/squirrelmail/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD
$request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH
$content_length;
fastcgi_param SCRIPT_FILENAME
$request_filename;
fastcgi_param SCRIPT_NAME
$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT
$document_root;
fastcgi_param SERVER_PROTOCOL
$server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE
nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with
--enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
# To access SquirrelMail, the default user (like
www-data on Debian/Ubuntu) must be used
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~*
^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$
{
root /usr/share/;
}
}
location /webmail {
rewrite ^/* /squirrelmail last;
}
location /cgi-bin/mailman {
root /usr/lib/;
fastcgi_split_path_info (^/cgi-bin/mailman/[^/]*)(.*)$;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with
--enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /images/mailman {
alias /usr/share/images/mailman;
}
location /pipermail {
alias /var/lib/mailman/archives/public;
autoindex on;
}
}
000-ispconfig.vhost
server {
listen 8080;
ssl on;
ssl_certificate /usr/local/ispconfig/interface/ssl/ispserver.crt;
ssl_certificate_key /usr/local/ispconfig/interface/ssl/ispserver.key;
# redirect to https if accessed with http
error_page 497 https://$host:8080$request_uri;
server_name _;
root /usr/local/ispconfig/interface/web/;
client_max_body_size 20M;
location / {
index index.php index.html;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/ispconfig.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~ /\. {
deny all;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/ispconfig.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~*
^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$
{
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
location /squirrelmail {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/squirrelmail/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/ispconfig.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~*
^/squirrelmail/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$
{
root /usr/share/;
}
}
location /webmail {
rewrite ^/* /squirrelmail last;
}
}
100-mydomain.com.vhost
server {
listen *:80;
server_name mydomain.com www.mydomain.com;
root /var/www/mydomain.com/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_log /var/log/ispconfig/httpd/mydomain.com/error.log;
access_log /var/log/ispconfig/httpd/mydomain.com/access.log combined;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file
/var/www/clients/client1/web1/web/stats/.htpasswd_stats;
}
location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}
location ~ \.php$ {
try_files /b4c43b69af764469f45973ffea6ff69d.htm @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9010;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
Edit: So i want when i type the ip of the vps ex. 5.55.33.7 to show a
certain page and not the website that is hosted in this ip.

ubuntu in a virtual box

ubuntu in a virtual box

I need to run ubuntu through Oracle vm virtual box. Can someone please
walk me through it? do I download ubuntu first then open the vm and
install it there? or do I need an image? very new to this please help!

Monday, 30 September 2013

Wirelss problem with RT3290 in ubuntu 13.04

Wirelss problem with RT3290 in ubuntu 13.04

I have a hp pavilion laptop with rt3290 wifi device. The original driver
provided by ralink corporation compiles in 12.04 but fails to compile in
13.04 (I guess this is a problem with kernel..). Also the inbuilt driver
rt2800 works fine at some places, but can not connect at others.It shows
the available networks but does not connect....Any Help???

Showing the sequence is monotone, bounded, and finding the limit

Showing the sequence is monotone, bounded, and finding the limit

The problem I am having is figuring out the way show the following
sequence is monotone:
let $x_1 = \frac{3}{2}$ and $x_{n+1} = {x_n}^2-2x_n+2$, show that the
sequence $x_n$ is monotone and bounded and find the limit.
I have found the first three terms, and found that the sequence is
decreasing, I have followed an example in my text that is the opposite
however my text is vague and I'm not sure how they found where the
sequence is bounded I am led to believe by math that it is bounded by 1.
any hints or suggestions on how to approach the problem would bennefit me
greatly
thanks

array_shift but preserve keys

array_shift but preserve keys

My array looks like this:
$arValues = array( 345 => "jhdrfr", 534 => "jhdrffr", 673 => "jhrffr", 234
=> "jfrhfr" );
How can I remove the first element of an array, but preserve the numeric
keys? Since array_shift changes my integer key values to 0, 1, 2, ....
I tried using unset( $arValues[ $first ] ); reset( $arValues ); to
continue using the second element (now first), but it returns false.
How can I achieve this?

Build FFmpeg with xCode 5

Build FFmpeg with xCode 5

Does anyone know how to compile FFmpeg with xCode 5?
My configure part:
./configure --disable-doc --disable-ffmpeg --disable-ffplay
--disable-ffserver --enable cross-compile --arch=arm --target-os=darwin
--enable-neon --disable-avfilter \ --disable-bsfs \ --enable-avresample
--enable-swresample --disable-iconv --enable-gpl \ --disable-demuxers
--enable-demuxer=rtsp --enable-demuxer=rtp --enable-demuxer=mpegts \
--disable-decoders --enable-decoder=mp2 --enable-decoder=mp3
--enable-decoder=mpeg2video --enable-decoder=ac3 - enable-decoder=dvbsub
--enable-decoder=h264 \ --disable-parsers --enable-parser=mpegvideo -
enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=dvbsub\
--disable-muxers --disable-encoders --disable-filters \
--disable-protocols --enable-protocol=http --enable-protocol=rtp
--enable-protocol=udp --enable-protocol=tcp \ --disable-swscale-alpha \
--disable-armv5te \ --disable-armv6 \ --disable-armv6t2 \
--cc=/Applications/Xcode.app/Contents/Developer/usr/bin
--as='/usr/local/bin/gas preprocessor/gas-preprocessor.pl
/Applications/Xcode.app/Contents/Developer/usr/bin'
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
--cpu=cortex-a8 --extra-cflags='-arch armv7 -mfpu=neon -mfloat-abi=softfp'
--extra-ldflags='-arch armv7 -mfpu=neon -mfloat-abi=softfp -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk'
--enable-pic --disable-bzlib
It works with xCode 4 (different Compiler-Path)
Error-Message:
./configure: line 3763: nm: command not found

Sunday, 29 September 2013

semicolon as character in c++ char array

semicolon as character in c++ char array

I'm trying to create a character array which holds a single symbol per
array index with the following code:
#ifndef TABLEDEFS_H
#define TABLEDEFS_H
#include <string>
using namespace std;
char symbolTable[] = {'_', '=', '<', '>', '!', '+', '-', '*', '/', '%', '.',
'(', ')', ',', '{', '}', ';', '[', ']', ':'};
string tokenTable[] = {"IDtk", "NUMtk", "==", "=<=", "=>=", "=", "<", ">",
"!",
"+", "-",
"*", "/", "%", ".", "(", ")", ",", "{", "}", ";", "[", "]", ":", "EOFtk"};
string keywordTable[] = {"Start", "Stop", "Then", "If", "Iff", "While",
"Var", "
Int", "Float", "Do",
"Read", "Write", "Void", "Return", "Dummy", "Program"};

How to Change Button Foreground and Background When Pressed and Released

How to Change Button Foreground and Background When Pressed and Released

Currently I have a need to place a 'back' button within my application.
This is not to replace the hardware back button, but to go back to a
previous state of an item if the user does not wish to continue with his
or her change of an item. Currently I have the following xaml for my
MainPage, which binds an image as well as places the 'back' button on the
view as well.
MainPage.xaml
<Grid x:Name="MainPageGrid" Margin="{Binding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=".2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image x:Name="currentPhoto" Grid.ColumnSpan="5"
Grid.RowSpan="2"
Source="{Binding Source}" Margin="12,0,12,12"
HorizontalAlignment="Center"
VerticalAlignment="Center"
toolkit:TiltEffect.IsTiltEnabled="True"/>
<Button x:Name="photoRefreshButton" Grid.Row="0"
Grid.Column="5"
BorderBrush="Transparent"
Click="photoRefreshButton_Click"
toolkit:TiltEffect.IsTiltEnabled="True">
<Image Source="Assets/Buttons/back.png"/>
</Button>
</Grid>
I would like to be able to toggle the foreground and background when the
button is pressed and released, but I am unsure of how to change the
button template style for this. I would like to use the following setup:
Not Pressed
Foreground = #FF1BA1E2 (ARGB: 255, 27, 161, 226)
background = transparent
Pressed
Foreground = Current theme foreground brush
background = transparent

Automatic form submission using JS

Automatic form submission using JS

I am developing a code, which takes a value as input and the form when
submitted, displays the result and the code is as follows:
<script>
function submitme()
{
document.forms["myform"].submit();
}
</script>
<body onload="submitme()">
<FORM name="performance" id="myform" method="post"
action="http://www.pvpsiddhartha.ac.in/index.sit" >
<INPUT type="hidden" name="service"
value="STU_PERFORMANCE_MARKS_DISPLAY">
<TABLE border="0" width="100%" cellspacing="0" cellpadding="0">
<TR>
<TD colspan="2" align="center"><STRONG><U>Student Marks
Performance Display Form</U></STRONG></TD>
</TR>
<TR><TD>&nbsp;</TD></TR>
<TR>
<TD align="right" width="40%">Regd. No:</TD>
<TD><INPUT type="text" name="stid" value="<?php echo
$_GET['x']; ?>"></TD>
</TR>
<TR><TD>&nbsp;</TD></TR>
<TR>
<TD align="right"><INPUT type="submit" name="submit"
value="Submit"></TD>
<TD align="center"><INPUT type="reset" value="Clear"></TD>
</TR>
</TABLE>
</FORM>
</body>
The problem is, when the page is loaded completely, the form should be
submitted , but the form cannot be submitted. What is the problem , Help
me!! Thanks in advance

Saturday, 28 September 2013

CSS Code working on Mac browsers but not on Windows browsers?

CSS Code working on Mac browsers but not on Windows browsers?

I have the following CSS:
font-family: 'HelveticaNeue-UltraLight', 'Helvetica Neue UltraLight',
'Helvetica Neue', Arial, Helvetica, sans-serif; font-weight: 100;
letter-spacing: 1px; }
It works on all Mac browsers (Chrome, Safari) But I opened my project on
Chrome and Internet explorer on Windows, it displays the font as bold
rather than light. I'm not sure how to fix this but I need the design to
work cross platform with the design that appears on mac.
Thanks in advance.

How to input values to HashMap in bean using Primefaces?

How to input values to HashMap in bean using Primefaces?

I have a page where I have to associate two fields using key-value pair
and save. For example, I have a number of participants who has prices. If
I use two p:inputText fields to enter their values, how should the backing
bean look like?
Also, I want to display the number of such pairs of p:inputText fields
according to the number of participants I enter. I have a similar question
answered here How to insert a primefaces input text dynamically?. But I
want to be able to submit the values to a key-value pair.

Ubuntu boot-repair problems

Ubuntu boot-repair problems

I used Gparted to decrease my Windows-partition and to increase my Ubuntu
13.04 partition. After restarting my pc, ubuntu doesn't start and I used
Boot-repair to reinstall GRUB2. Now I can only boot with Ubuntu-Live-CD or
get to the grub-terminal.
I hope this helps: Ubuntu Boot-repair info
Thanks!

PHP - Username must only contain letters, numbers and underscores

PHP - Username must only contain letters, numbers and underscores

I am making a registration form for a website and want to check that the
username must only contain letters, numbers and underscores. it cant
contain spaces, commas, dots,slashes or any other symbol. I want to do it
with the function preg_match. can you please help me writing a good
validation code?thanks in advance.

Friday, 27 September 2013

What is a better way in php for variables

What is a better way in php for variables

This:
$var = true
if(1 > 0){
$var = false
}
or this:
if(1 > 0){
$var = false
} else {
$var = true
}

How to put data to array and search by specifically row?

How to put data to array and search by specifically row?

I query from mytable like this.

I want to put it in array(PHP) and search like this
$index = 15;
$result = array_search(...)..); <--- age_range
and put that row ($result) to new array i created; Or somebody hav better
idea. Sorry some stupid question. Thank for help.
query
SELECT
CONCAT(2 * FLOOR(age / 2), '-', 2 * FLOOR(age / 2) + 5) AS 'age_range',
SUM(gload1) AS 'g1',
SUM(gload2) AS 'g2',
SUM(gload3) AS 'g3',
SUM(gload4) AS 'g4',
SUM(gload5) AS 'g5',
SUM(gload6) AS 'g6',
SUM(gload7) AS 'g7',
SUM(gload8) AS 'g8',
SUM(gload9) AS 'g9',
SUM(gload10) AS 'g10'
FROM
member
GROUP BY 1
ORDER BY age ;

Heading in alt-tag (alt='Test')

Heading in alt-tag (alt='Test')

I have an image with a link. If there, for some reason, is no image I
would like the "image" to display a heading. I am coding this in PHP, and
this is my line of code:
<a href='LINK.php?img=$id'><img src='$filename' alt='<h1>$username</h1>'
width='500'></a>
It is not working, and the out put is "
jerry>
" in plain text, no heading, if the $username is jerry.
How can I fix the problem?

How to tell GCC to generate 16-bit code for real mode

How to tell GCC to generate 16-bit code for real mode

I am writing real mode function, which should be normal function with
stackframes and so, but it should use %sp instead of %esp. Is there some
way to do it?

Access 2007, VBA: Printing only the CURRENT selected record from three forms

Access 2007, VBA: Printing only the CURRENT selected record from three forms

This is my code so far. This prints the current selected record from my
first form. I want the button to also print current selected records from
2 other forms (they have the same emp name).
Dim myform As Form
Dim pageno As Integer
pageno = Me.CurrentRecord
Set myform = Screen.ActiveForm
DoCmd.SelectObject acForm, myform.Name, True
DoCmd.PrintOut acPages, pageno, pageno, , 1
DoCmd.SelectObject acForm, myform.Name, False

MySQL performance - large database

MySQL performance - large database

I've read heaps of posts here on stackoverflow, blog posts, tutorials and
more, but I still fail to resolve a rather nasty performance issue with my
MySQL db. Keep in mind that I'm a novice when it comes to large MySQL
databases.
I have a table with approx. 11.000.000 rows (will increase to say
20.000.000 or more). Here's the layout:
CREATE TABLE myTable ( intcol1 int(11) DEFAULT NULL, charcol1 char(25)
DEFAULT NULL, intcol2 int(11) DEFAULT NULL, charcol2 char(50) DEFAULT
NULL, charcol3 char(50) DEFAULT NULL, charcol4 char(50) DEFAULT NULL,
intcol3 int(11) DEFAULT NULL, charcol5 char(50) DEFAULT NULL, intcol4
int(20) DEFAULT NULL, intcol5 int(20) DEFAULT NULL, intcol6 int(20)
DEFAULT NULL, intcol7 int(11) DEFAULT NULL, id int(10) unsigned NOT NULL
AUTO_INCREMENT, PRIMARY KEY (id), FULLTEXT KEY idx (charcol2,charcol3) )
ENGINE=MyISAM AUTO_INCREMENT=11665231 DEFAULT CHARSET=latin1;
A select statement like "SELECT * from myTable where charchol2='bogus' AND
charcol3='bogus2'; takes 25 seconds or so to execute. That's too slow, and
will be even slower as the table grows.
The table will not have any inserts or updates at all (so to speak), and
will be primarily used for outputting searches on the char-columns.
I've tried to make indexing work (playing around with FULLTEXT, as you can
see), but it seems that I'm missing something. Any takes on how to speed
up the performance?
Please note: Im currently running MySQL on my Macbook Air (1.7 GHz i5, 4GB
RAM). If this is the only answer to my performance issues, I'll move the
database to something appropriate ;-)

Thursday, 26 September 2013

Get browserproperty textsize for IE

Get browserproperty textsize for IE

I have to react on browserproperties like zoom and textsize. To determine
the zoomlevel I calculate screen.deviceXDPI/screen.logicalXDPI which works
fine.
However I also need to know the textsize (normal, larger, ...) to enlarge
an iframe where the content is in. The solution have to be for IE(9).
I know that iframes are not state of the art but it is given... Thanks!

Thursday, 19 September 2013

No valid APS environment

No valid APS environment

I've been trying to submit my application to the Apple Store and keep
getting a email that says,"no valid aps-environment entitlement found for
application."
I created a new Push Notification Certificates and then generated new
provisioning profiles, but to no avail. Every time I look at the binary
details of the application it says that there's isn't a aps-environment.
I'm not sure what is going wrong. I though about erasing my App ID and
resubmitting, but nothing seems to work.
I'm trying to release a new version too. Is there a way to cancel the upload?

Find function in text

Find function in text

I'm re-designing a mathematics program for students. The original program
was written in adobe flash. This time I am doing it in PHP and Javascript.
In the original program there are several xml files with hundreds of
mathematical questions and some of which are fractions. Those fractions
are written as: #(1,4). I want to make an function called # which can make
classic fractions.
The problem: there is normal text around the #(1,3) and it is not
separated with quotations. How can I let the browser know there is a
function in the text? Example:
<question>what is #(2,8) divided by #(3,4)</question>
I hope you know how to do this. Thanks.

Mysql query based on date?

Mysql query based on date?

I have a table like this
id | date | content
1 | 09-16-2013 | content 1 here
2 | 09-23-2013 | content 2 here
3 | 09-30-2013 | content 3 here
I would like to display the content for a week from that date. For
example, the first content should start on 9/16/2013 and then show until
9/22/2013 mid night. then on next day, it changes to the content 2. Same
way,when I am on content 2, I want to display like "previous week content"
and then show just the previous ones..I think I can do this by checking
the current date and then anything below that has to be displayed.
I am not very good at these kind of mysql queries, please advise!
Regards

MailCore Framework CTSMTPConnection sendMessage

MailCore Framework CTSMTPConnection sendMessage

I have integrated the MailCore (1) Framework and my app is building and
running without any errors. the sendMessage method returns true but there
is no message on the sender account or on the receiver account.
#import <MailCore/MailCore.h>
This is how I am using MailCore
CTCoreMessage *msg = [[CTCoreMessage alloc] init];
CTCoreAddress *toAddress = [CTCoreAddress
addressWithName:[[users objectAtIndex:0] name]
email:[[users objectAtIndex:0] email]];
[msg setTo:[NSSet setWithObject:toAddress]];
[msg
setSubject:NSLocalizedString(@"forgotPasscodeEmailSubject",
nil)];
[msg setBody:@"Test"];
NSError *error;
BOOL success = [CTSMTPConnection sendMessage:msg
server:@"server" username:@"account" password:@"123456"
port:587 connectionType:CTSMTPConnectionTypeStartTLS
useAuth:YES error:&error];
Btw I`m using HostEurope SMTP Server.

Enabling/Disabling a button after database query

Enabling/Disabling a button after database query

I want to disable or enable a button, depending on the result of a
database-query. But I don't know how. From an example, I managed to show a
text (id="error", depending on the result of the query, but enabling the
button (id="generate") does not work.
This is my JavaScript:
function checkSender(str)
{
if(str == "")
{
str=document.getElementById("senderinput").value;
}
str=str.toUpperCase();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("error").innerHTML=xmlhttp.responseText;
if(xmlhttp.responseText == "Einsender existiert nicht.")
{
document.getElementById("generate").disabled = true;
}
else
{
document.getElementById("generate").disabled = false;
}
}
}
xmlhttp.open("GET","checkSender.php?s="+str,true);
xmlhttp.send();
}
The response from checkSender.php is either "Einsender existiert nicht."
or an empty string.
Any suggestions?
Thanks in advance!
Marco Frost

ios uiscrollview addsubview not working

ios uiscrollview addsubview not working

I am new at IOS development, but I have a problems with UIScrollView.
First of all, I have created Scroll View in storyboard and added
@property (retain, nonatomic) IBOutlet UIScrollView *mainScroll;
in view controller handler
In viewDidLoad method I have that code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mainScroll.contentSize = CGSizeMake(100.0,100.0); // Have to set
a size here related to your content.
// You should set these.
self.mainScroll.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
self.mainScroll.minimumZoomScale = .5; // You will have to set some
values for these
self.mainScroll.maximumZoomScale = 2.0;
self.mainScroll.zoomScale = 1;
UIButton* b = [[UIButton alloc] init];
[b setBounds:CGRectMake(.0f,0.f,100.0,100.0)];
[self.mainScroll addSubview:b];
}
But nothing appears in the simulator. However if I add button on
storyboard in IB, button appears and I can scroll the view.
P.S. sorry for my language

cannot access Frame, file does not contain class frame

cannot access Frame, file does not contain class frame

import java.awt.*;
class FirstFrame extends Frame {
FirstFrame() {
Button b = new Button("ok");
b.setBounds(30, 100, 80, 30);
add(b);
setSize(400, 400);
setLayout(null);
setVisible(true);
}
public static void main(String args[]) {
FirstFrame f = new FirstFrame();
}
}

Wednesday, 18 September 2013

Compatibility of Javascript, HTML and CSS inside IFrame or nested IFrames

Compatibility of Javascript, HTML and CSS inside IFrame or nested IFrames

I have an existing web site which is about to use a dynamic menu
navigation system. To short, all the existing pages will be moved into
iFrame's of the menu page.
JQuery, YUI Ajax, simple manual Javascript Ajax and variety of other
Javascript libraries are used across all hurdreds pages.
My concern here is the compatibility issues that might come up when
existing pages, with or without iFrame, are moved into menu iFrame.
For your information, my web site is developed by using Classic ASP.
Please refer me to a similar thread or just let me know your opinion.
Thanks in advance.

Languages to context free grammars

Languages to context free grammars

Provide context free grammars for the following languages.
(a) {a^mb^nc^n | m ¡Ý 0 and n ¡Ý 0 }
(b) {a^nb^nc^m | m ¡Ý 0 and n ¡Ý 0 }
If there were any other rules involved such as m = n or anything like
that, I could get it, but the general m greater than or equal to zero? I'm
pretty confused. and also I don't understand how a and b would be any
different. Here was my shot at making a grammar out of this:
S1 --> S2 | e
S2 --> aS2bS2c | S3
S3 --> aS3 | S4
S4 --> bS4 | S5
S5 --> cS5 | c

Using append() from Jquery outside the HTML document

Using append() from Jquery outside the HTML document

I am trying to use Jquery in a separate .JS file since keeping all
JavaScript code out of the HTML document will increase the performance of
loading the HTML document.
For this example I am using "index.html" and "main.js"
Below is index.html:
<html lang="en">
<head>
<meta charset="utf-8">
<title>append demo</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="testJS/main.js"></script>
</head>
<body>
<p>I would like to say: </p>
<!-- CODE BELOW MUST BE REMOVED FROM THIS DOCUMENT -->
<script>
$( "p" ).append( "<strong>Hello</strong>" );
</script>
</body>
</html>
I would like to cut the code from the html and insert it into main.js
however the example below did not work for me:
main.js:
p.append( "<strong>Hello</strong>" );
I've also tried this with no success:
$( "p" ).append( "<strong>Hello</strong>" );
How could I fix this and what is the difference between having JavaScript
inside and having it inside a .js file?

Upgrading interface builder document?

Upgrading interface builder document?

After opening an old iOS 6 App Xcode asked me if I wanted to upgrade my IB
doc to version 5.0 or skip. I hit skip so I could learn about what it
would do first.
Now I'm unable to find a way to re-upgrade the document?

Get aggregation values for all possible distinct entries in group by

Get aggregation values for all possible distinct entries in group by

Ok, I know the title is confusing, but the idea is pretty simple. I just
need to figure out how many flights were flown at five different sites
during a given time period. Sometimes a site won't have any flights during
the period and this is where I'm having the problem. If I use:
select count(*)
from Flight
where date between '9/9/2013' and '9/15/2013'
group by Site
order by Site
I will only get the sites that have actually flown, but I would like to
have those sites where there were no flights during during that period
(but have flown at other times and have records in the table) still return
a value of 0.

Does using /u modifier in PCRE cause any problemm if unicode is not used?

Does using /u modifier in PCRE cause any problemm if unicode is not used?

/u modifier is used in PCRE when we use unicode characters like /x{0xFF0}.
Does it cause any problem if we have a regex like /^\d{10}$/u (e.g. using
unicode modifier when unicode is not used in regex) ? I ask this because I
get different results in localhost and production server(using preg_match
function)
And if it doesn't cause any problem, why this modifier is not used by
default?

Python minidom parsing xml gives None or empty string instead of values from xml

Python minidom parsing xml gives None or empty string instead of values
from xml

I am trying to parse SAP results xml file (generated in soapUI) in Python
using minidom and everything goes smoothly until it comes to retrieving
values. No matter what type of node it it, value printed is "None" or just
empty string. Nodes have different types and only value I can get so far
is tag name for element node. When it comes to it's value I get None. For
text one I get '#text' for nodeName, 3 for nodeType, but empty string for
nodeValue
This start to makes me crazy. What is wrong?
The code is:
from xml.dom.minidom import parse, Node
def parseData():
try:
data = parse('data.xml')
except (IOError):
print 'No \'data.xml\' file found. Move or rename the file.'
Milestones = data.getElementsByTagName('IT_MILESTONES')
for node in Milestones:
item_list = node.getElementsByTagName('item')
print(item_list[0].childNodes[1].nodeName)
print(item_list[0].childNodes[1].nodeType)
print(item_list[0].childNodes[1].nodeValue)
while important part of XML structure looks like that:
<IT_MILESTONES>
<item>
<AUFNR>000070087734</AUFNR>
<INDEX_SEQUENCE>2300</INDEX_SEQUENCE>
<MLSTN>1</MLSTN>
<TEDAT>2012-08-01</TEDAT>
<TETIM>09:12:38</TETIM>
<LST_ACTDT>2012-08-01</LST_ACTDT>
<MOBILE>X</MOBILE>
<ONLY_SL/>
<VORNR>1292</VORNR>
<EINSA/>
<EINSE/>
<NOT_FOR_NEXT_MS>X</NOT_FOR_NEXT_MS>
</item>
</IT_MILESTONES>

Reading a text file line by line and storing it in an array using batch script

Reading a text file line by line and storing it in an array using batch
script

I want to read a text file and store each line in an array.When i used the
code below, "echo %i%" is printing 0 every time and only array[0] value is
getting assigned.But in "set n=%i%",n value is assigned as the last
incremented i value.Also "@echo !array[%%i]!" is printing like !array[0]!
instead of printing the value.Is there any syntax error in the code?
set /A i=0
for /F %%a in (C:\Users\Admin\Documents\url.txt) do (
set /A i+=1
echo %i%
set array[%i%]=%%a
)
set n=%i%
for /L %%i in (0,1,%n%) do @echo !array[%%i]!

Tuesday, 17 September 2013

How to set the config in wcf for https?

How to set the config in wcf for https?

I have the following config file for wcf work prefectly under http, but
somehow this is not working unser https. Does anyone know what is going
wrong there? and how can I fix it?
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<!-- if using basicHttpBinding, wsHttpBinding section should be
commented -->
<wsHttpBinding>
<binding name="wsHttpBindingConfig">
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" />
<message clientCredentialType="None"
negotiateServiceCredential="False" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="SEWebService.Service1"
behaviorConfiguration="SEWebService.Service1Behavior">
<!-- basicHttpBinding is SOAP-based Service, it sends data in
plain text, but it supports maximum types of clients.
It supports Soap 1.1, lower version of .Net Client, like .Net 1.1 -->
<!--
<endpoint address="basic" binding="basicHttpBinding"
contract="SearchApi.ISearchApi"/>
-->
<!--wsHttpBinding is SOAP-based Service, it sends encrypted data
by default, but it needs supporting WS-* specification clients and
at least .Net3.0 or higher version
By default wsHttpBinding uses Windows authentication, we need to
turn it off by using bindingConfiguration-->
<endpoint address="ws" binding="wsHttpBinding"
contract="SEWebService.IService1"
bindingConfiguration="wsHttpBindingConfig" >
</endpoint>
<!-- webHttpBinding is non-SOAP HTTP services, here webHttpBinding
register REST to be a Restful WCF Service
It uses [WebGet] or [WebInvoke] to map an Http Request to a WCF
operation-->
<endpoint address="" binding="webHttpBinding"
contract="SEWebService.IService1" behaviorConfiguration="REST">
<!--Upon deployment, the following identity element should be
removed or replaced to reflect the identity under which the
deployed service runs.
If removed, WCF will infer an appropriate identity
automatically.-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SEWebService.Service1Behavior">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="80" />
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
<!-- To avoid disclosing metadata information, set the value
below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging
purposes, set the value below to true. Set to false before
deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value
below to true.
Set to false before deployment to avoid disclosing web app folder
information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
<connectionStrings>
<add name="DbConnectionString" connectionString="nitial
Catalog=Smart_Web_Service;uid=SmartWebService_User;pwd=dzB3RiCK2zb73E;Connect
Timeout=10; pooling=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

Wrapper that hides away game/physics maths

Wrapper that hides away game/physics maths

I was wondering if there was any wrappers that hide away the math of game
programming. For example I don't care about terms like normalise - I'd
rather just get information I as a game programmer need.
// too math-oriented
Vector2 dir = a.position - b.position;
dir.Normalise();
// much better
DirectionVector2 dir = DirectionVector2.AToB(a.position, b.position);
or even
// true if ball has gone off-screen
// 'dot', 'normal', ugh...
if (Vector2.Dot(WallNormal, WallToBallDir) < 0)
// true if ball has gone off-screen
if (DirectionVector2.GetAngle(WallFacingDir, WallToBallDir) == Angles.Obtuse)
or even even
// some stuff
Matrix world = translation * rotation * scale * 100 other things.
Vector2 rotation = new Vector2(world.m23, world.m33, world.m44);
// made easier
Transform objWorld = new Transform(translateVector, rotVector, scaleVector);
Vector2 rotation = objWorld.rotation;
These are just some off the top of my head. I feel like all of the math
functions ('atan2', 'cos', etc) could just be simplified to getAngle, or
getLength etc. Anyone else agree?
I know I could write this wrapper myself, but I was wondering if
potentially anyone else had started one already for DirectX/XNA.

Refer properties in Spring expression language

Refer properties in Spring expression language

I have a field as shown below which works
@Value("#{T(java.util.regex.Pattern).compile('[0-9]+')}")
private Pattern myPattern;
But if I change it to
@Value("#{T(java.util.regex.Pattern).compile('${myProp}')}")
private Pattern myPattern;
it does not work. Is there a way to refer properties inside Spring
expression?

Seling PHP scripts built with framework

Seling PHP scripts built with framework

I'm a web developer, and I'm develop in PHP for few years. And I write a
lot of scripts for exercise and for clients. Usually scripts was on
demand, with special purpose. Sometimes I used frameworks and sometimes I
write code from beginning.
I recently thought about can I sell scripts built with frameworks? I'm
very familiar with Symfony 2 and Laravel, and I'm asking you guys, will it
be successfull?? My english is not very good, I'm not asking about ideas
or something, but if I have a good CMS, forum, social network or something
else built with framework, would people buy it?
What is your opinion?
P.S. Again, sorry for my bad english, I home that you can understand me

Forensics of Google Now Cards

Forensics of Google Now Cards

I'm doing some forensics research on Google Now on Android devices,
specifically looking for traces of Google Now cards. I've found some
interesting looking MD5 hash filenames in
/data/data/com.google.android.googlequicksearchbox/cache/http:
ec3e155cd9468332b96f281f391698d2.0
ec3e155cd9468332b96f281f391698d2.1
f557c74614fff426f32fd1235c1a0aaf.0
f557c74614fff426f32fd1235c1a0aaf.1
It looks like the files ending in .0 contain links to the graphics used on
the cards. Can someone explain what the .1 files contain? Looks like
either encrypted or binary data when I open them in a text editor. Do the
.1 files contain the rest of the Google Now card content and can they be
viewed somehow?
Thanks, Justin

How To Setup Apache behind nginx

How To Setup Apache behind nginx

I want to run Apache behind nginx. because, i want to use (.htaccess)
Rewrite rules. Currently Apache is running on port 80 with nginx running
on port 8080. nginx to serve only static files (jpg,png,css,js...) rest of
the things to handle by Apache.
Which apache mod? mod_rpaf or mod_proxy
Apache & nginx configuration?

Sunday, 15 September 2013

wxpython redirect the text to the textctrl in real-time

wxpython redirect the text to the textctrl in real-time

wxpython how to redirect the text to the textctrl in real-time
I know how to redirect the text , but the textctrl show the text until the
process end, I want to show the text in real-time
import sys,time
import wx
class RedirectText(object):
def __init__(self,aWxTextCtrl):
self.out=aWxTextCtrl
def write(self,string):
self.out.WriteText(string)
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "wxPython Redirect
Tutorial")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
log = wx.TextCtrl(panel, wx.ID_ANY, size=(300,100),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
btn = wx.Button(panel, wx.ID_ANY, 'Push me!')
self.Bind(wx.EVT_BUTTON, self.onButton, btn)
# Add widgets to a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(log, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
# redirect text here
redir=RedirectText(log)
sys.stdout=redir
def onButton(self, event):
print "You pressed the button!"
time.sleep(5)
print "======End====="
# Run the program
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = MyForm().Show()
app.MainLoop()
can you give me a full example code. I need it.

Java Animations

Java Animations

I've started to take interest with making animations(slideshows,
backgrounds etc) in Java. I know that JavaFX is much better for doing
this, but I'm just to stubborn to bother switching over.
Here is what I got so far.
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class BlurredLightCells extends JPanel {
private static final long serialVersionUID = 4610174943257637060L;
private Random random = new Random();
private ArrayList<LightCell> lightcells;
private float[] blurData = new float[500];
public static void main(String[] args) {
JFrame frame = new JFrame("Swing animated bubbles");
frame.setSize(1000, 750);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new BlurredLightCells(60));
frame.setVisible(true);
}
public BlurredLightCells(int amtOfBCells) {
setSize(1000, 750);
/**
* Below we initiate all the cells that are going to be drawn on screen
*/
Arrays.fill(blurData, 1f / 20f);
lightcells = new ArrayList<LightCell>(amtOfBCells);
for (int i = 0; i < amtOfBCells; i++) {
/**
* Below we generate all the values for each cell(SHOULD be random
for each one)
*/
int baseSpeed = random(0, 3);
int xSpeed = (int) Math.floor((Math.random() * (baseSpeed -
-baseSpeed + baseSpeed)) + -baseSpeed);
int ySpeed = (int) Math.round((Math.random() * baseSpeed) + 0.5);
int radius = random(25, 100);
int x = (int) Math.floor(Math.random() * getWidth());
int y = (int) Math.floor(Math.random() * getHeight());
int blurrAmount = (int) (Math.floor(Math.random() * 10) + 5);
int alpha = (int) ((Math.random() * 15) + 3);
/**
* Now we draw a image, and apply transparency and a slight blur
to it
*/
Kernel kernel = new Kernel(blurrAmount, blurrAmount, blurData);
BufferedImageOp op = new ConvolveOp(kernel);
BufferedImage circle = new BufferedImage(150, 150,
BufferedImage.TYPE_INT_ARGB);
Graphics2D circlegfx = circle.createGraphics();
circlegfx.setColor(new Color(255, 255, 255, alpha));
circlegfx.fillOval(20, 20, radius, radius);
circle = op.filter(circle, null);
LightCell bubble = new LightCell(x, y, xSpeed, ySpeed, radius,
getDirection(random.nextInt(3)), circle);
lightcells.add(bubble);
}
}
public int random(int min, int max) {
final int n = Math.abs(max - min);
return Math.min(min, max) + (n == 0 ? 0 : random.nextInt(n));
}
@Override
public void paint(Graphics g) {
int w = getWidth();
int h = getHeight();
final Graphics2D g2 = (Graphics2D) g;
GradientPaint gp = new GradientPaint(-w, -h, Color.LIGHT_GRAY, w, h,
Color.DARK_GRAY);
g2.setPaint(gp);
g2.fillRect(0, 0, w, h);
long start = System.currentTimeMillis();
for (int i = 0; i < lightcells.size(); i++) {
LightCell cell = lightcells.get(i);
cell.process(g2);
}
System.out.println("Took " + (System.currentTimeMillis() - start) + "
milliseconds to draw ALL cells.");
repaint();
}
public String getDirection(int i) {
switch (i) {
case 0:
return "right";
case 1:
return "left";
case 2:
return "up";
case 3:
return "down";
}
return "";
}
private class LightCell {
private int x, y, xSpeed, ySpeed, radius;
private String direction;
private BufferedImage image;
public LightCell(int x, int y, int xSpeed, int ySpeed, int radius,
String direction, BufferedImage image) {
this.x = x;
this.y = y;
this.xSpeed = xSpeed;
this.ySpeed = ySpeed;
this.radius = radius;
this.direction = direction;
this.image = image;
}
public void process(Graphics g) {
switch (direction) {
case "right":
moveRight();
break;
case "left":
moveLeft();
break;
case "up":
moveUp();
break;
case "down":
moveDown();
break;
}
g.drawImage(image, x, y, null);
}
private void moveUp() {
x += xSpeed;
y -= ySpeed;
if (y + (radius / 2) < 0) {
y = getHeight() + (radius / 2);
x = (int) Math.floor(Math.random() * getWidth());
}
if ((x + radius / 2) < 0 || (x - radius / 2) > getWidth()) {
y = radius + (radius / 2);
x = (int) Math.floor(Math.random() * getWidth());
}
}
private void moveDown() {
x += xSpeed;
y += ySpeed;
if (y - (radius / 2) > getHeight()) {
y = 0 - (radius / 2);
x = (int) Math.floor(Math.random() * getWidth());
}
if ((x + radius / 2) < 0 || (x - radius / 2) > getWidth()) {
y = getHeight() + (radius / 2);
x = (int) Math.floor(Math.random() * getWidth());
}
}
private void moveRight() {
x += ySpeed;
y += xSpeed;
if (y - (radius / 2) > getHeight() || y + (radius / 2) < 0) {
x = 0 - (radius / 2);
y = (int) Math.floor(Math.random() * getHeight());
}
if ((x - radius / 2) > getWidth()) {
x = 0 - (radius / 2);
y = (int) Math.floor(Math.random() * getWidth());
}
}
private void moveLeft() {
x -= ySpeed;
y -= xSpeed;
if (y - (radius / 2) > getHeight() || y + (radius / 2) < 0) {
x = getWidth() + (radius / 2);
y = (int) Math.floor(Math.random() * getHeight());
}
if ((x + radius / 2) < 0) {
x = getWidth() + (radius / 2);
y = (int) Math.floor(Math.random() * getWidth());
}
}
}
}
If you run that, you will see the cells move at a very high speed, and if
you look through the code, you see I call repaint() in the paint method in
which I override. I know thats not good to do. But my question is, is
their any other way in which I could draw each cell outside of the
repaint() loop I have right now, because that causes other components to
flash/flicker when I use this in a JFrame with other components.
Thanks!

“Indentation Error: unindent does not match any outer indentationlevel”

"Indentation Error: unindent does not match any outer indentation level"

can you please tell me what is wrong with this code?
def insert_sequence(str1, str2, index):
'''The first two parameters are DNA sequences and the third parameter
is an index. Return the DNA sequence obtained by inserting the second
DNA sequence into the first DNA sequence at the given index.
>>>insert_sequence('CCGG', 'AT',2)
CCATGG
'''
str1 = str1[0:index] + str2 + str1[index:len(str1)]
return str1

iostram.h error when compiling a C code

iostram.h error when compiling a C code

I want to compile this code with GCC, using terminal :
#include <iostream.h>
#include <stdlib.h>
int main()
{
char card_name[3];
puts("Enter the card_name:");
scanf("%2s", card_name);
int val = 0;
if (card_name[0] == 'K') {
val = 10;
} else if (card_name[0] == 'Q') {
val = 10;
} else if (card_name[0] == 'J') {
val = 10;
} else if (card_name[0] == 'A') {
val = 11;
} else {
val = atoi(card_name);
}
printf("The card value is : %i\n", val);
return 0;
}
But I got an error : fatal error: iostream.h: No such file or directory
What is the problem ? Please explain complete .

Dropdownlist onChange event is never called using javascripts

Dropdownlist onChange event is never called using javascripts

I need a value from my dropdownlist present in my jsp to a servlet class.
The jsp contains
<select name="DropDownList1" onchange="change(this);">
<option value="A">A</option>
<option value="B">B</option>
</select>
<script type="text/javascript">
function change(sel)
{
var url1=sel[sel.selectedIndex].value;
var toServer = myJSONObject.toJSONString();
var request=new XMLHttpRequest();
request.open("POST",
"http://localhost:8080/test/Testing?stringParameter="+stringParameter
, true);
request.send(toServer);
return false;
}
Now the problem is that the onchange event is never called and nothing
happens! What do i do?

CADisplayLink timestamp precision

CADisplayLink timestamp precision

I've been trying in vain to understand what the floating point value of
CADisplayLink.timestamp is. Is it in nanoseconds? Seconds? What is its
precision?

stdint.h for Java?

stdint.h for Java?

Is there a java library implementing the standard data types as they are
available in C?
In Java everything is signed, so using byte to store uint8_t comes with
some problems, for example:
byte test = (byte) 0xf3;
System.out.println("test = " + test);
prints
test = -13
instead of
test = 243
I think of something like this:
UInt8 test = new UInt8(0xf3);
System.out.println("test = " + test.toInt());

Saturday, 14 September 2013

which is the best method to move php code out of js in ajax

which is the best method to move php code out of js in ajax

I am developing an application in Yii.. One issue i am facing is, when i
am writing ajax functions, the url's will be in php. so i am unable to
move the codes to another javascript file.
$.ajax({
url: "<?php echo
Yii::app()->createUrl('provider/ajaxdetail');?>",
data: {'type':tagtype},
beforeSend: function() { },
success: function(data) {
}
});
so what is the best method to move php out of the javascript so that i can
move the javascript code to another js file. I Thought of putting the
url's in a hidden box and then call it in the javascript function. but i
hope there will be better methods to do this .
please help

Spring 3 MVC and Tiles 2.2

Spring 3 MVC and Tiles 2.2

I have configured a Spring MVC / Hibernate / Tiles application. All was
working until I introduced the Tiles component. I believe I have it right
but I keep getting "Cannot render a null template" exception
Here is my root-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- DispatcherServlet Context: defines this servlet's
request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<context:component-scan base-package="com.acts542.mygunshop" />
<mvc:interceptors>
<bean class="com.acts542.mygunshop.controller.SecurityInterceptor" />
</mvc:interceptors>
<!-- Handles HTTP GET requests for /resources/** by efficiently
serving up static resources in the ${webappRoot}/resources directory
-->
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp
resources in the /WEB-INF/views directory -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
<bean
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/tiles.xml</value>
</list>
</property>
</bean>
<bean id="myDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mygunshop"/>
<property name="username" value="mygunshop"/>
<property name="password" value="sen32164"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="packagesToScan">
<array>
<value>com.acts542.mygunshop.model</value>
<value>com.acts542.mygunshop.dao</value>
<value>com.acts542.mygunshop.service</value>
<value>com.acts542.mygunshop.controller</value>
</array>
</property>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="hibernate.hbm2ddl.auto">create</prop> -->
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- The definition of the Root Spring Container shared by all
Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Here is my tile.xml
<!DOCTYPE tiles-definitions PUBLIC
"-//ApacheSoftwareFoundation//DTDTilesConfiguration2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="template" template="WEB-INF/tiles/mainLayout.jsp">
<put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/tiles/menu.jsp" />
<put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
<put-attribute name = "content" value="/WEB-INF/views/Login.jsp" />
</definition>
<definition name = "Login">
<put-attribute name = "content" value="/WEB-INF/views/Login" />
</definition>
<definition name = "Home" extends="template">
<put-attribute name = "content" value="/WEB-INF/views/Home" />
</definition>
</tiles-definitions>
Here is my mainLayout.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<title>This is a test!</title>
</head>
<body>
<table border="1" style="border-collapse: collapse;" cellpadding="2"
cellspacing="2" align="center" width="100%">
<tbody>
<tr>
<td width="20%" rowspan="3">
<tiles:insertAttribute name="menu" />
</td>
<td width="80%" height="20%">
<tiles:insertAttribute name="header" />
</td>
</tr>
<tr>
<td width=80% height="60%">
<tiles:insertAttribute name="content" />
</td>
</tr>
<tr>
<td height="20%">
<tiles:insertAttribute name="footer" />
</td>
</tr>
</tbody>
</table>
</body>
</html>
LoginController.java
package com.acts542.mygunshop.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.acts542.mygunshop.dto.BusinessMessage;
import com.acts542.mygunshop.dto.LoginDto;
import com.acts542.mygunshop.form.LoginForm;
import com.acts542.mygunshop.service.LoginService;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
@Controller
@RequestMapping({"/", "/Login"})
public class LoginController
{
private static final Logger logger =
LoggerFactory.getLogger(LoginController.class);
LoginService loginService;
@Autowired
public void setLoginService(LoginService loginService)
{
this.loginService = loginService;
}
@RequestMapping(method = RequestMethod.GET)
public String processGet(Map<String, LoginForm> model)
{
LoginForm loginForm = new LoginForm();
model.put("form", loginForm);
return "Login";
}
@RequestMapping(method = RequestMethod.POST)
public String processPost(@Valid @ModelAttribute("form") LoginForm form,
BindingResult result, HttpSession session)
{
if (result.hasErrors())
{
return "Login";
}
LoginDto loginDto = new LoginDto();
loginDto.setUserName(form.getUserName());
loginDto.setPassword(form.getPassword());
loginDto = loginService.loginEmployee(loginDto);
if(null == loginDto)
{
result.addError(new ObjectError("form", "User Not Found"));
result.addError(new ObjectError("form", "Please Try Again"));
return "Login";
}
if(loginDto.getMessages().hasMessages())
{
result.addError(new ObjectError("form",
loginDto.getMessages().getMessage()));
List<BusinessMessage> messages =
loginDto.getMessages().getMessages();
if(null != messages)
{
Iterator<BusinessMessage> iterator = messages.iterator();
while(iterator.hasNext())
{
result.addError(new ObjectError("form",
iterator.next().getMessage()));
}
}
return "Login";
}
session.setAttribute("LoggedOnEmployee", loginDto);
return "redirect:/Home";
}
}
Exception
SEVERE: Servlet.service() for servlet appServlet threw exception
org.apache.tiles.impl.InvalidTemplateException: Cannot render a null template
a t
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:51)
at
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
at
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
at
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
at
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
at
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
at
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
at java.lang.Thread.run(Thread.java:662)
Tried everything - except what you guys might add. Again, everything
seemed to be working and wired correctly. Had the Login render the login
page Post the user / password in a form made a return trip tom to the DB
and rendered the Home page. Once I plugged in Tiles, I can't the first
page to render.

upload file dont work properly on my server

upload file dont work properly on my server

function upload_cover(){
$config_cover['upload_path'] = 'img/blog/';
$config_cover['allowed_types'] = 'gif|jpg|png|tif';
get_instance()->load->library('upload', $config_cover);
if($this->upload->do_upload('myFile') )
{
$upload_data = $this->upload->data();
$path = 'img/blog/'.$upload_data['file_name'];
return $path;
}
}
function upload_file(){
$config_file['upload_path'] = 'img/blog/';
$config_file['allowed_types'] = 'doc|docx|pdf|txt|xls|xlsx|ppt|pptx';
$this->upload->initialize($config_file);
if ($_FILES['myDoc']) {
if($this->upload->do_upload('myDoc'))
{
$upload_data = $this->upload->data();
$path = 'document/blog/'.$upload_data['file_name'];
return $path;
}
}
}
these code are work properly on my computer but when i deploy it on my
server it's work only "upload_cover" but upload_file is not working im
have no idea.... someone please help,thanks a lot...