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...

How to create Bluetooth connection in Windows Phone 8?

How to create Bluetooth connection in Windows Phone 8?

I need way to create connection between two Bluetooth(windows phone 8 App
& computer PC) I am create App on Windows Phone 8 but I need to create
Bluetooth connection between my App on Windows Phone 8 and PC Computer and
transfer image(stream) between them by this connection .

Migrating to iOS 7: Adjusting ToolBar height -- tool bar items squeezed into status bar

Migrating to iOS 7: Adjusting ToolBar height -- tool bar items squeezed
into status bar

I am migrating my iOS 6 application to iOS 7 and have issues with the new
height of my toolbar.
I have not changed the toolbar's default parameters (all set to default,
height = 44, inferred, etc), but it seems that the label and image
(country flag) are squeezed into the status bar:

I also played with the new iOS 6 / iOS 7 Delta Settings in the View
Settings, but nothing has changed.
Do you have any idea on what might be wrong?

Can i make cname point to remote URL directory

Can i make cname point to remote URL directory

I have the remote url like this
http://www.abc.com/my data/files and i want to make my subdomain point to
this like
media.mydomain.com to that so that if i have file like
http://www.abc.com/my data/files/abc.pdf then i can serve it via
media.mydomain.com/abc.pdf

How to ignore directories and files only inside a directory

How to ignore directories and files only inside a directory

I have this .gitignore file:
app/cache/*
app/logs/*
app/bootstrap*
vendor/*
web/bundles/
app/config/parameters.yml
web/public/img/users/*
but I want the directory web/public/img/users not to be ignored (only
files inside). I mean, when a git clone repo is done, the directory must
be made, but not the files inside. How can I do it?

Friday, 13 September 2013

how to remove emulator starting error

how to remove emulator starting error

Starting emulator for AVD 'hello' emulator: WARNING: Could not initialize
OpenglES emulation, using software renderer. RenderServer::create failed
to listen emulator: emulator window was out of view and was recentered it
seems too many emulator instances are running on this machine. Aborting

Create a bean and autowire it

Create a bean and autowire it

I currently have numerous classes with a field like
private MyStuff myStuff = new MyStuff();
It would be preferable if there was a MyStuff singleton which all the
classes used. Our project has a MyConfiguration class with some Beans in
it, but they don't seem to get used, at least not directly, so I can't use
them for examples. I have been tasked to create a MyStuff bean in the
MyConfiguration class, and then inject it into my other classes.
What I have so far:
@Configuration
public class MyConfiguration
{
@Bean
public MyStuff myStuff()
{
return new MyStuff();
}
}
public SomeClass
{
public void dealWithStuff()
{
myStuff.myMethod();
}
@Autowired
private MyStuff someStuff;
}
This does not compile. The compiler says "variable someStuff may not have
been initialized". Apparently it does not see the bean or make the
connection. What am I missing?

How can I get these java line algorithms working?

How can I get these java line algorithms working?

I'm trying to demonstrate Bresenham's line algorithm as opposed to a less
sophisticated approach. I'm very new to programming and I'm sure my
problems are elementary, but a solution and an explanation would be hugely
helpful. Thanks!
This first block of code comes straight out of my book.
import java.awt.*;
import javax.swing.*;
public class lines extends JPanel {
int deltaX;
int deltaY;
int DY2;
int DX2;
int Di;
public void basic(int x1, int y1, int x2, int y2, Graphics
g){
int deltaX = x2-x1;
int deltaY = y2-y1;
float m = (float)deltaY/(float)deltaX;
float c = y1 - (m*x1);
for (int x=x1; x<x2; x++){
float floatY = (m*x) + c;
int y = Math.round(floatY);
g.drawLine(x,y,x,y);
}
}
public void brz(int x1, int y1, int x2, int y2,
Graphics g){
deltaX = x2-x1;
deltaY = y2-y1;
DY2 = 2* deltaY;
DX2 = 2* deltaX;
Di = DY2 - deltaX;
int x = x1;
int y = y1;
int prevy;
while (x<x2) {
x++;
prevy = y;
if (Di > 0){
y++;
}
g.drawLine(x,y,x,y);
Di = Di + DY2 - (DX2 * (y - prevy));
}
}
public void paintComponent(Graphics g){
basic(10,10,40,30,g);
basic(10,10,40,90,g);
brz(50,50,150,60,g);
brz(50,50,150,120,g);
brz(50,50,150,140,g);
}
It told me I need a main class, so I added this bit:
public static void main(String[] args) {
paintComponent(Graphics g);
}
Now it's giving me this:
lines.java:15: ')' expected paintComponent(Graphics g);
lines.java:15: illegal start of expression paintComponent(Graphics g);

Adding variables in javascript

Adding variables in javascript

I am looking for some help. I'd like to be able to add 2 variables and
then set one of the variables to a higher digit.
function gain_points() {
var total_points = parseInt(0)
var points_per_click = parseInt(1)
var points_per_second = parseInt(0)}
I'd like to be able to add total_points and points_per_click together, and
then for that to increase total_points.
Is this possible?

get file path from DnD files upload

get file path from DnD files upload

I'm using FILES API of html5 to improve my page can be upload file by
using drag and drop feature , But I need after DnD file , we click on Save
button , then this file will be convert into StreamReader format before
upload to server !
So anyone can tell me how to got it ? Is it possible if I can get file
path from DnD event ?
Thanks all in advance !

Depending on where I put the "println" it only sometimes works

Depending on where I put the "println" it only sometimes works

Below is a snip from my code. The problem is it is not printing out the
"yay! keep smiling!" at the end. It only prints it if I place the println
before the if loop. How can I fix this? I am sorry if this is a stupid
question, I am new to programming.
for (int z = 0; z <= p; z++) {
char guessCorrelation = correctWord.charAt(z);
if (guessCorrelation == input) {
String temp = dashword.substring(0, z) + guessCorrelation +
dashword.substring((z + 1), (p));
dashword = temp;
System.out.println(dashword);
decider = 1;
if (dashword.equals(correctWord)) {
System.out.println("I knew you had it in you to save gumbo!");
}
}
}
System.out.println("yay! keep smiling!");

Hebrew font is not printing in Flex

Hebrew font is not printing in Flex

I have a project on Flex using Adobe Air and it will be on an Android
Device and it's multi-language. I have few .properties files that content
the different text/sentences depending the device language and i'm using a
[resourceManagement.getString] to call this sentences.
One of the languages it's Hebrew, i haven't a problem with the RTL&LTL but
when i'm trying to "print" them characters i didn't see them on the
simulator or any device, i used different fonts (i take them for different
sites where explain how to show this characters) but it doesn't work. I
think it's a problem with the resourceManagement class, i used a TextFlow
too, but it only print a character in unicode and i have a lot text so i
can use it because i need print the text that i have in my properties and
it's in Hebrew. I'm using UTF-8.
Thanks!

Thursday, 12 September 2013

Android 'set As Wallpaper' functionality

Android 'set As Wallpaper' functionality

I am developing an application in which I have an image gallery and when I
click on any image, it opens in full mode. But I want the set As Wallpaper
functionality like android default gallery:

I know it can be done by custom code (setting wallpaper and cropping
image). But I want to pass that image to android default wallpaper setter
so that android will manage the cropping and setting wallpaper task. How
can I do that? How can I pass that image to android default walpaper
setter?

ListView Card layout Scrollbar and spacing issues

ListView Card layout Scrollbar and spacing issues

I have attached a screenshot of my app with some junk data. The white that
takes up the entire ListView is supposed to only be for each item,
creating a card layout. I am new to Android, and cannot figure out where
my code makes the incorrect reference.
The layout for the individual card is here: http://pastebin.com/mxjiDTLF
The layout for the activity is here: http://pastebin.com/kstW9PqV
The EventAdapter.java class that displays the Event objects in the
listview is here: http://pastebin.com/vXkBnPq0
Also, in the below screenshot, you can see that the scrollbar does not
appear right next to the left edge of the screen, but just inside the
"white" of the massive card. What do I need to do so that it does not
appear there?

Recreate 3 column facebook style parcial scrolling then fixed position CSS

Recreate 3 column facebook style parcial scrolling then fixed position CSS

Hi i want to know how to achieve the facebook effect for its 3 columns, if
you check you can scroll the page as a usual page until the right column
stop scrolling, and the center scrolling keep doing it, How is that 3er
column on the right working, why you can scroll it until its fixed on the
page.. i guess this is javascript. right?
For the rest of elements i think header is fixed , thats clear, but that
3er column is killing me cause i need to recreate a timeline (with other
design) but the same idea of 3 columns..
Any ideas? All the examples i can found, set a fixed position for Rigth
column , but in facebook as i said you can scroll until 3rd column became
fixed, well i think i dont know, thats why i ask.
Thanks

php/Codeigniter-- How to compare only date by excluding time

php/Codeigniter-- How to compare only date by excluding time

i have a field in my db table as creater_date as datetime and having
values stored in the form of 2013-09-13 02:12:44
Now i have to compare today-date(no time) with creater_date table field .
I tried this below code but it is showing error :
function check_existing_User_weightStatus($u_id)
{
$this->load->database();
$this->load->helper('date');
$today = date('Y-m-d');
$array = array('creater_id' => $u_id,DATE('created_date') => $today);
$this->db->where($array);
$query = $this->db->get('user_weight');
if ($query->num_rows() > 0) {
return true;
} else {
return false;
}
}
Getting error :
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '13 Sep
2013 02:48:27 +0530Asia/Calcuttaam30Asia/Calcutta13_13am30Asia/Calcutta
'' at line 4
SELECT * FROM (`user_weight`) WHERE `creater_id` = '3235' AND
`2013-09-13T02:48:27+05:30Fri,` 13 Sep 2013 02:48:27
+0530Asia/Calcuttaam30Asia/Calcutta13_13am30Asia/Calcutta '2013-09-13'
Filename: D:\xampp\htdocs\webapp\system\database\DB_driver.php
Line Number: 330

Django commands interacting

Django commands interacting

I have the following situation: I have one django command that is
listening to an outside source for information. I don't know how long said
stream is, what the format or what the terminating sequence is. So I was
thinking that I would listen indefinitely using one command and have
another command stop the listening at some point. The issue is that since
the two commands are running in separate python shells, I can't seem to
set a global variable to share between the two. Something like:
globalvar = True
class Command(NoArgsCommand):
def handle_noargs(self, **options):
global globalvar
while globalvar:
print "Is True"
time.sleep(1)
and
class Command(NoArgsCommand):
def handle_noargs(self, **options):
global globalvar
globalvar = False
The variable globalvar doesn't exist in the context of the second command.
Is there any way other than storing the information in the database that I
can somehow stop/alter the way the first command is running?

How to use ASP.NET Response Filters on sites where dynamic compression is enabled

How to use ASP.NET Response Filters on sites where dynamic compression is
enabled

I've developed a simple ASP.NET response filter (with this as my base
filter class: http://mvolo.com/iis-70-response-modification-framework/)
that replaces some html with something else.
The things works great sometimes...but sometimes I get the following error:
====
This response filter does not support processing compressed responses.
Please disable static compression when using the filter, or use on the fly
dynamic compression to compress the response after the filter is finished
(do not use dynamicCompressionBeforeCache).
Do you have an explanation of why it happens just intermittently...and
especially how this can be solved? Thanks! :)

Crashes when pushing to viewcontroller - Objective c

Crashes when pushing to viewcontroller - Objective c

My app getting crashed when I try to push to a view controller. Its
happening only when we try to navigate to another page(both push and
presentModal). And I also checked the IBoutlets and other connections in
view controller where it should be pushed. But can't find a clue. Here is
my code where I do the push:
PhoneBookView *phoneBook = [[PhoneBookView alloc]
initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];
[self.navigationController presentModalViewController:phoneBook
animated:YES];
Thanks.

Wednesday, 11 September 2013

How do I get tabs to appear in an ActionBar when using ActionBarDrawerToggle?

How do I get tabs to appear in an ActionBar when using ActionBarDrawerToggle?

I have a FragmentActivity (HomeFragment) that utilizes NavigationDrawer
and ActionBarDrawerToggle. When I run the emulator with this
FragmentActivity as the first displayed FragmentActivity to the user, I
see the ActionBar and the NavigationDrawer works perfectly. From here I am
able to select a menu item ("Account") which takes me to an
AccountFragment. My AccountFragment activity uses a ViewPager to swipe
between a fragment for basic account info and another fragment for a list
of buddies/contacts. My BuddiesFragment is supposed to add navigation tabs
to the actionbar to select buddies from a list, from groups, or from
favorites. I cannot get these tabs to appear under my action bar.
It is worth mentioning that if I start my emulator directly accessing the
BuddiesFragment and skipping navigating to this fragment from my
HomeFragment, the navigation tabs appear underneath the actionbar as
expected. I can't figure out the difference that causes one usecase to
fail but not the other.
I do not have enough 'reputation points' to post picture for clarification.
public class BuddiesFragment extends AbstractBaseFragment implements
ActionBar.TabListener {
private final String[] buddyTabs = new String[] {"Buddy List", "Buddy
Groups", "Buddy Favorites"};
private final String TAG = "BuddiesFragment";
BuddyListAdapter adapter;
NonScrollablePager pager;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//getActivity().getActionBar().hide();
View view = inflater.inflate(R.layout.buddies_info_layout, container,
false);
adapter = new BuddyListAdapter(getFragmentManager());
pager = (NonScrollablePager) view.findViewById(R.id.scroll_pager);
pager.setAdapter(adapter);
final ActionBar actionBar = getActivity().getActionBar();
// Specify that the Home/Up button should not be enabled, since there
is no hierarchical
// parent.
actionBar.setHomeButtonEnabled(false);
// Specify that we will be displaying tabs in the action bar.
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
pager.setOnPageChangeListener(new
ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// When swiping between different app sections, select the
corresponding tab.
// We can also use ActionBar.Tab#select() to do this if we
have a reference to the
// Tab.
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < adapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined
by the adapter.
// Also specify this Activity object, which implements the
TabListener interface, as the
// listener for when this tab is selected.
actionBar.addTab(
actionBar.newTab()
.setText(adapter.getPageTitle(i))
.setTabListener(this));
}
return view;
}
The AccountFragment has a ViewPager that allows me to swipe to
AccountInfoFragment and BuddiesFragment. It does not manipulate the
ActionBar whatsoever.
public class AccountFragment extends AbstractBaseFragment {
private CirclePageIndicator pageIndicator;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//getActivity().getActionBar().hide();
View view = inflater.inflate(R.layout.account_layout, container, false);
AccountPagerAdapter apa = new AccountPagerAdapter(getFragmentManager());
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.pager);
mViewPager.setAdapter(apa);
pageIndicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
pageIndicator.setViewPager(mViewPager);
return view;
}

sql list number of people born every year

sql list number of people born every year

I have a table with two columns, name and year of birth(from 1960-1980).
How can I write a single sql query which lists each year and the number of
people born that year? something like:
Year Number of people born
1960 5
1961 3
1962 4
... ..
1980 4

How can we use group functions on IObservable while observing is not finished or on hot, long running observable

How can we use group functions on IObservable while observing is not
finished or on hot, long running observable

I have the following Observable
IObservable<int> observable = Observable.Range(0, 10);
I have the following subscriptions
observable.Subscribe(v => Console.WriteLine("Received value: " + v);
observable.Sum().Subscribe(s => Console.WriteLine("Sum so far: " + s);
My desired output is following
Received value: 0
Sum so far: 0
Received value: 1
Sum so far: 1
Received value: 2
Sum so far: 3
...
...

But what I am actually getting is the Sum after receiving the final value
of the series.
My actual goal is to fit this into the puzzle where I have a Hot,
continuously running observable giving me decimal values and I have to
subscribe() to the current average and sum values.
Any help in this will be appreciated.

Integer to Boolean

Integer to Boolean

I'm new to python and I pray that I'm not bashed for this question... As a
computer science major I feel it's only right to ask at least ONE question
on stackoverflow.
How do I use an integer value as a boolean without the use of functions?
Here's the question:
You will be given a series of mathematical and logical tasks. Implement
these ONLY using variables and operators. No loops, conditionals,
functions or data structures should be used. You will only be working with
the basic data types: Integer, Float, String, and Boolean.
Operators that you can use: +, -, , /, %, *, //, ==, !=, <>, >, <, >=, <=,
=, +=, -=, =, /=, %=, *=, //=, and, or, not, &, |, ^, ~, <<, >>
Given:
a = 5
b = 7
Task: Implement xor (abbreviation for 'exclusive or'). Xor should be true
if a and b are not the same. Store the value of a xor b in a variable
named output. Example: 2 xor 9 = True
I know it would be extremely easy to do: output = bool(a^b)
However... I can't use functions :/
a^b=12 which is a true value... I just don't know how to get that to
represent a boolean value.

asp.net drop downlist value reset on button click within jquery dialog

asp.net drop downlist value reset on button click within jquery dialog

I have a div , within which I have a button and an asp.net dropdownlist. I
can change the value in the dropdownlist . But as soon as the button is
clicked the value in the drop down list is again set to the default
initial value. Is there a way I can solve this problem ? I do not want the
dropdownlist to go back to its initial value.
aspx
<div id='one'>
<asp:LinkButton ID="ConfigureAlerts"
OnClick="btnConfigureAlerts_Click" runat="server">Configure
Alerts</asp:LinkButton>
</div>
<div id="ViewModalPopupDiv2">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server"
HorizontalAlign="left" ScrollBars="Auto">
<asp:Button ID="btnGetLogs" runat="server"
Text="SendAlerts" OnClick="btnSendAlertEmail_Click"/>
<asp:Label ID="Label2" runat="server" Text="Set The Alert Email Interval
to every :" CssClass="label"
ForeColor="Black"></asp:Label>&nbsp&nbsp&nbsp
<asp:DropDownList ID="ddlTimeInterval" runat="server" >
<asp:ListItem Text="15MIN"
Value="15"></asp:ListItem>
<asp:ListItem Text="30MIN"
Value="30"></asp:ListItem>
<asp:ListItem Text="1Hr"
Value="60"></asp:ListItem>
<asp:ListItem Text="2Hrs"
Value="120"></asp:ListItem>
<asp:ListItem Text="8Hrs"
Value="480"></asp:ListItem>
<asp:ListItem Text="24Hrs"
Value="1440"></asp:ListItem>
<asp:ListItem Text="48Hrs"
Value="2880"></asp:ListItem>
</asp:DropDownList>
<br />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
javascript
function ViewModelPopup2() {
$("#ViewModalPopupDiv2").dialog({
scrollable: true,
width: 800,
modal: true
});
}
ASPX.CS
protected void btnSendAlertEmail_Click(object sender, EventArgs e)
{
// Code to send email
}
protected void btnConfigureAlerts_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript
(this, this.GetType(), "callScriptFunction",
"ViewModelPopup2();", true);
}
}

Joining 2 tables where table2 contains multiple rows for each table1 row

Joining 2 tables where table2 contains multiple rows for each table1 row

I'm either over-thinking this or my SQL skills are lacking. I need to add
two columns to a table from a second table, but the values are in separate
rows in the second table. What SQL would do this? Here's an example.
transnum is the common column between the tables.
TABLE1
------
transnum id
9287 006
5782 004
5819 001
TABLE2
------
transnum code value
9287 A 198.38
9287 B 928.57
9287 C 568.25 -- code C values not needed
5782 A 219.53
5782 B 591.11
5782 C 852.32
5819 A 109.92
5819 B 251.81
5819 C 295.12
DESIRED RESULT
--------------
transnum id valueA valueB
9287 006 198.38 928.57
5782 004 219.53 591.11
5819 001 109.92 251.81

Eclipse wont generate R file after ADT 22 Update

Eclipse wont generate R file after ADT 22 Update

I recently updated to ADT 22.0.5 and now my projects wont generate the R
file. I have followed all steps posted in other questions and still have
no luck. Any suggestions? I have lost way to much time on this.

CUDA - Precision difference in Release version between with and without debug information

CUDA - Precision difference in Release version between with and without
debug information

I have a CUDA application, which I compile once for a Release version
twice: once with debug info (-G used) and once without debug info. I run
the application which does some computations on floats (including
functions such as expf, sinf, cosf, etc.). I notice that there are slight
differences in the numbers created by the two versions, here they are side
by side:
0: (-8.000000,0.000000,0.000000) 0: (-8.000000,0.000000,0.000000)
1: (-8.212574,-0.112065,0.970697) 1: (-8.212575,-0.112065,0.970697)
2: (-8.365530,-0.250361,1.949206) 2: (-8.365531,-0.250361,1.949206)
3: (-8.332600,-0.251884,2.948662) 3: (-8.332601,-0.251885,2.948662)
4: (-8.593035,-0.619825,3.841295) 4: (-8.593036,-0.619826,3.841295)
5: (-8.507285,-0.778658,4.824870) 5: (-8.507286,-0.778658,4.824870)
6: (-8.441058,-1.001207,5.797539) 6: (-8.441058,-1.001207,5.797539)
7: (-8.680929,-1.051136,6.767059) 7: (-8.680929,-1.051136,6.767059)
These are the first 7 values (both versions start with -8,0,0). As you can
see at this point there are only small differences in the 6th digit after
the decimal point. However, I use these during rotation matrix
computation, so after 1000 of these, the differences add up to be quite
significant.
I'm not adding the source code because it is very big and quite complicated.
I was wondering why is there a difference in the first place. I know that
there are vast differences between debug and release versions in terms of
optimizations. I guess there are similar differences between release with
and without debug info. However, how could optimizations change
calculation precision?

Is C compiler a pure form of compilers

Is C compiler a pure form of compilers

Can a compiler build using C be called a pure form of compiler.
Is there anything related to I/O systems that makes C not a pure compiler.
for example
printf("%s=%d" , "x" , 10)
How does C compiler interprets this?

Tuesday, 10 September 2013

Add jquery to a html element that is added dynamically.

Add jquery to a html element that is added dynamically.

I have <video> elements added to the page when an image is clicked. A
light box with the video pops up. What would be the best way to execute a
snippet of jquery to this dynamic video element? I though maybe some form
of the .on method might work was not sure.

Jquery's eq(0), "..first-child", first() not grabbing first child if its an iframe

Jquery's eq(0), "..first-child", first() not grabbing first child if its
an iframe

Basically I need to grab the first child of a parent element, usually but
not limited to an <iframe>.
<div>
<iframe src="www.asource.com">GRAB THIS AFTER A BUTTON IS
CLICKED</iframe>
</div>
I have tried the following
$("#parent").eq(0).prop("tagName");
$("#parent").first().prop("tagName");
$("#parent:first").prop("tagName");
$("#parent:nth-child(1)").prop("tagName");
$("#parent:lt(1)").prop("tagName");
All of these return a "div" when I alert them. The reason I am getting the
prop name was because I wanted to use the find() to get the element.
$("parent").find(ONE OF THE PROP CALLS ABOVE).animate({.....
because when I do:
$("parent").find('**iframe**').animate({.....
that is the only scenario that I can grab and properly animate an iframe.
however since we don't know if the first child is an iframe or not, i used
.prop() to get the first element tag name and find it. (please note, i
tried all the above attempts directly with .animate(...) instead of
.prop(...) but that also didn't grab the iframe. Would really appreciate
some guidance