Tuesday, 10 September 2013

Making cross domain get request

Making cross domain get request

okay so I have this link
<a id="link" href="https://yahoo.com" target="blank">Link</a>
then i have this script:
var security = function(){
var link = $('#link').attr('href');
$.getJSON('http://myweb.com/func.php',function(result){
if (result % 5 === 0){
$('#link').attr("href", link);
alert('his link');
}else{
$('#link').attr('href','https://google.com');
alert('your link');
}
});
$("#link").click(function(){
$.getJSON('http://myweb.com/func2.php',function(results){
if (results === results){
location.reload();
}
});
});
};
func.php:
$results = mysqli_query($con,"SELECT * FROM `c_clicks`");
while ($row = mysqli_fetch_array($results)) {
$clicks = $row['id'];
echo $clicks;
}
func2.php:
$results = mysqli_query($con,"INSERT INTO `c_clicks`(`link`,`date`)
VALUES('claim',now())");
What I'm trying to accomplish is that for every 5 clicks the #link will
send the user to another domain. The thing is it works fine but if someone
rips my website and switches the #link href func.php and func2.php are no
longer accesible so they dont work. I tried fixing it with JSON but im
guessing its wrong. How could I still perform func and func2 through a
different server?

Converting a python script to a web application

Converting a python script to a web application

I have a python script written up and the output of this script is a list
. Right now I need to get it online and make it accesible to others. I
looked at Django , but then I realised that it may be kind of hard to
create the UI. Is there any simple way to create a UI in Django and map it
to an existing python script. Right now I am not using sql and things like
that. Or is there a simpler way by which I can proceed?

Eclipse java - how to add full line with double quotes

Eclipse java - how to add full line with double quotes

I'm programming in Eclipse and i have a SQL script that got multiple lines:
SELECT * FROM
.... (bla bla)
... (bla bla )..
... (bla bla bla bla)
I have to add the double quotes like this:
" SELECT * FROM "
+ ".... (bla bla) "
+ "... (bla bla ).."
+ "... (bla bla bla bla) "
Is there any SHORTCUT to do this in Eclipse?

How to export 0.5 million rows to excel/csv (performance issue)?

How to export 0.5 million rows to excel/csv (performance issue)?

Currently we are using NPOI for exporting some large data to
excel(environment--asp.net mvc-4.0 ). Its taking us around a minute to
export 30000 rows to excel. Now the requirement has changed and we want
500000 which is more then 10 times the current rows. NPOI serializer has
some limitations which is having drastic performance
issue..http://npoi.codeplex.com/discussions/443655 ...So after trying lot
of alternatives we decided that we will export this huge chunk of data to
csv file. Before starting with this code change I wanted to get an expert
opinion on how to handle this scenario where you have to deal with such a
massive number of rows export... Is exporting to CSV a better option???
Can any one point out a code sample or an article that has a solution to
data export to csv/excel for more the 0.5 million rows within a 1 min
timeframe..

Wordpress menu CSS Classes is not working

Wordpress menu CSS Classes is not working

I want to change the color of one of the tabs of the menu bar in Wordpress
using menu CSS Classes, I added the class name in my style file, but when
I add the class name in the CSS Classes in the Admin->Menu page it's not
working. that's the class name in the style file it's very simple.
.red{
color: #ff0000;
}

curve fitting using multiple starting points for every variable

curve fitting using multiple starting points for every variable

Given a random parametric function with n parameters used to fit
datapoints. You define you're parametric function by heigthmodel You're n
startingvalues are defined as initial values For the fitting you use
lsqcurvefit(heigthmodel,initialvalues,...
Is there a way you can give more then one startingvalue for every
parameter. So that you add another string of startingvalues and the model
will start from both startingvalues and will return the best result?
I've already setup something like this:
Heightmodel = ....
Startingvalues = a1 a2 a3 a4 a5
Startingvalues = b1 b2 b3 b4 b5
options=optimoptions(numberofvariables,2) % based on the TypicalX function.
lsqcurvefit(heightmodel,startingvalues,...,options)
It would be interesting to know if I could make this work and if so if I
could add more startingvalues. So I will have p strings of startingvalues
and numberofvariables,p
Also is there a way to present these startingvalues in a matrix form? So
that for the first variable the fitting can choose to start from both a1
or b1, for the second variable from both a2 or b2? ...
Greetings

Displaying value only once

Displaying value only once

I am new to jquery and js. I have this simple thing trying to achieve but
is not working.
Basically I am getting a collection of records and for age I want it to
display only once..
<tr>

<td>
</tr>
This works fine, but it displays value of age multiple times because of
#each. I tried to remove #each etc. nothing works. Please help. Thanks