Thursday, 3 October 2013

Canvas Page Section Missing from 'App on Facebook'

Canvas Page Section Missing from 'App on Facebook'

I have purchased a faebook competition script from Code Canyon. Within the
documentation it states that under the 'App on Facebook' there should be
an option to provide a link to the canvas page (not the canvas page URL
which is present but above this actually to the page).
I have sent the developer a screen shot and he is stating that there is a
problem with Facebook and this is indeed not correct and that I should
contact Facebook support to resolve this.
Any help appreciated.

Wednesday, 2 October 2013

Is there a Javascript program stepper to keep track of variables?

Is there a Javascript program stepper to keep track of variables?

I'm looking for a way to step through a Javascript program and visualize
the variable assignments. Something like the Python visualizer:
http://pythontutor.com/visualize.html
Does such a stepper exist?

Upload in Google Chrome not working

Upload in Google Chrome not working

I am creating simple file upload (for pictures). I tried in Opera and in
FireFox and uploading is working fine. But when I upload via Google
Chrome, picture is not uploaded. Can you please tell me where is problem:
here is php script that is used for storing picture in database
<?php
$id=$_SESSION['user_id'];
$user_id=$_SESSION['user_id'];
$album_id=$_POST['album'];
$max_size = 500; // Sets maxim size allowed for the uploaded
files, in kilobytes
// sets an array with the file types allowed
$allowtype = array('bmp', 'gif', 'htm', 'html', 'jpg', 'jpeg', 'mp3',
'pdf', 'png', 'rar', 'zip');
// if the folder for upload (defined in $updir) doesn't exist, tries to
create it (with CHMOD 0777)
/*if (!is_dir($updir)) mkdir($updir, 0777);*/
/** Loading the files on server **/
$result = array(); // Array to store the results and errors
// if receive a valid file from server
if (isset ($_FILES['files'])) {
// checks the files received for upload
$file_name=$_FILES['files']['name'];
$file_type=$_FILES['files']['type'];
$file_size=$_FILES['files']['size'];
$file_tmp=$_FILES['files']['tmp_name'];
for($f=0; $f<count($_FILES['files']['name']); $f++) {
$file_name = $_FILES['files']['name'][$f];
$random_name=rand();
// checks to not be an empty field (the name of the file to have more
then 1 character)
if(strlen($file_name)>1) {
// checks if the file has the extension type allowed
$type=explode('.', $file_name);
$type=end($type);
if (in_array($type, $allowtype)) {
// checks if the file has the size allowed
if ($_FILES['files']['size'][$f]<=$max_size*1000) {
// If there are no errors in the copying process
if ($_FILES['files']['error'][$f]==0) {
$query = mysql_query("SELECT username from users
WHERE id = '$id' ");
while($run=mysql_fetch_array($query)){
$username=$run['username'];
}
$query = mysql_query("SELECT
album.name an from album WHERE
album.id = '$album_id' ");
while($run=mysql_fetch_array($query)){
$album_name=$run['an'];
}
mysql_query("INSERT INTO photos VALUE ('',
'$album_id', '$random_name.jpg',
'$user_id')");
// Sets the path and the name for the file to be uploaded
// If the file cannot be uploaded, it returns error message
if (move_uploaded_file
($_FILES['files']['tmp_name'][$f],"./users/".$username."/".$album_name."/".$random_name.".jpg"))
{
/*$result[$f] = ' The file could not be copied, try again';*/
$result[$f] = '<b>'.$file_name.'</b> - OK';
}
else {
$result[$f] = ' The file could not be copied, try again';
}
}
}
else { $result[$f] = 'The file <b>'. $file_name. '</b> exceeds the
maximum allowed size of <i>'. $max_size. 'KB</i>'; }
}
else { $result[$f] = 'File type extension <b>.'. $type. '</b> is not
allowed'; }
}
}
// Return the result
$result2 = implode('<br /> ', $result);
echo '<h4>Files uploaded:</h4> '.$result2;
}
?>
and here is form that is used for picture uploading:
<form id="uploadform" action="uploaderimg.php" method="post"
enctype="multipart/form-data" target="uploadframe"
onSubmit="uploading(this); return false">
<br>
Select album:
<select name="album">
<?php
$query=mysql_query("SELECT id, name, user_id FROM album WHERE
user_id = '$id'");
while($run=mysql_fetch_array($query)){
$album_id=$run['id'];
$album_name=$run['name'];
$album_user = $run['user_id'];
echo "<option value='$album_id'>$album_name</option>";
}
?>
</select>
<br /><br />
<h1>Chose your photo/s</h1>
<br>
<input type="file" name="files[]" />
<input type="submit" value="UPLOAD" id="sub" />
</form>

how boost::spirit::lex token is recognized

how boost::spirit::lex token is recognized

I am learning to use boost::spirit. To do that, I wanted to create some
simple lexer, combine them and then start parsing using spirit. but the
result is quite confused:
Here's the lexer:
// #define BOOST_SPIRIT_LEXERTL_DEBUG
#define BOOST_VARIANT_MINIMIZE_SIZE
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <iostream>
#include <string>
using namespace boost::spirit;
using namespace boost::spirit::ascii;
enum tokenids
{
IDANY = lex::min_token_id + 10,
T_USER,
T_DOMAINLABEL,
T_CRLF
};
template <typename Lexer>
struct sip_token : lex::lexer<Lexer>
{
sip_token()
{
this->self.add_pattern
("ALPHANUM", "[0-9a-zA-Z]")
("MARK", "[-_.!~*'()]")
("UNRESERVED","{ALPHANUM}|{MARK}")
("USER", "({UNRESERVED})+" )
("DOMAINLABEL", "({ALPHANUM})+")
// ("DOMAINLABEL", "{ALPHANUM}|({ALPHANUM}({ALPHANUM}|-)*{ALPHANUM})")
;
this->self.add
("{USER}",T_USER)
("{DOMAINLABEL}", T_DOMAINLABEL)
("\r\n", T_CRLF)
(".", IDANY) // string literals will not be esacped by the library
;
}
};
template <typename Iterator>
struct sip_grammar : qi::grammar<Iterator>
// struct sip_grammar : qi::grammar<Iterator>
{
template <typename TokenDef>
sip_grammar(TokenDef const& tok)
: sip_grammar::base_type(start)
, c(0), w(0), l(0)
{
using boost::phoenix::ref;
using boost::phoenix::size;
using boost::spirit::qi::eol;
start = (
(qi::token(T_DOMAINLABEL))[++ref(c), ++ref(l)]
>> qi::token(T_CRLF) [++ref(w)]
)
;
}
std::size_t c, w, l;
qi::rule<Iterator> start;
};
int main(int argc, char* argv[])
{
typedef lex::lexertl::token<
char const*, boost::mpl::vector<std::string>
> token_type;
typedef std::string::const_iterator str_iterator_type;
typedef lex::lexertl::lexer<token_type> lexer_type;
typedef sip_token<lexer_type>::iterator_type iterator_type;
std::string str;
while (std::getline(std::cin, str))
{
if (str.empty() || str[0] == 'q' || str[0] == 'Q')
break;
else
str += "\r\n";
sip_token<lexer_type> siplexer;
sip_grammar<iterator_type > g(siplexer);
char const* first = str.c_str();
char const* last = &first[str.size()];
/*< Parsing is done based on the the token stream, not the character
stream read from the input. The function `tokenize_and_parse()` wraps
the passed iterator range `[first, last)` by the lexical analyzer and
uses its exposed iterators to parse the toke stream.
>*/
unsigned result = 0;
bool r = lex::tokenize_and_parse(first, last, siplexer, g);
if (r) {
std::cout << "Parsing OK" << g.l << ", " << g.w
<< ", " << g.c << "\n";
}
else {
std::string rest(first, last);
std::cerr << "Parsing failed\n" << "stopped at: \""
<< rest << "\"\n";
}
}
return 0;
}
//]
in code, I add "T_DOMAINLABEL" after "T_USER"C T_DOMAINLABEL always gets
parsing failure.seems lexer will match T_USER firstly. why is that? does
it mean I can't add these similar patterns together?

Tuesday, 1 October 2013

can't access variables in another javascript file

can't access variables in another javascript file

So i have link every file needed into the index.html file :
<script src="jquery.js"></script>
<script src="notify.js"></script>
<script src="script.js"></script>
i create an object in 'notify.js' :
var notify = {
newNotification : function(text) {
}
}
script.js :
alert(notify.newNotification);
When i try to access the 'notify' object in 'script.js', it works just
fine.But i want to use jquery so i add $(document).ready() to both of the
file like this:
notify.js
$(document).ready (
function() {
var notify = {
newNotification : function(text) {
}
}
}
)
Script.js:
$(document).ready (
function() {
alert(notify.newNotification);
}
)
And after i add that, it comes up with notify is not defined.What's wrong?
Can anyone explain why it doesn't work?

get value from json callback

get value from json callback

I am not trying to append flickr photos to my webpage. I am trying to
retrieve the latitude and longitude values from the json call back.
This is the code I have so far. Nothing happens when I load it into my
browser.
<!DOCTYPE html>
<html>
<head>
<title>Flickr Pie Chart</title>
<meta charset="utf-8">
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#driver").click(function(event){
var apiKey = '[YOUR API KEY]';
var url =
'http://api.flickr.com/services/rest/&method=flickr.photos.search&api_key='
+ apiKey
+'&per_page=500&tags=losangeles&has_geo=1&extras=geo,tags&format=json&jsoncallback=?';
$.getJSON(url, function(data){
//loop through the results with the following function
$.each(data.items, function(i,item){
var geoData +='latitude:' item.latitude + '' + '<br>';
geoData += '' + item.longitude;
$('#results').append(geoData);
});
});
});
});
</script>
</head>
<body>
<div id = "results"></div>
<input type="button" id="driver" value="Load Data" />
</body>
</html>

Enum flags in C# – stackoverflow.com

Enum flags in C# – stackoverflow.com

I am using Enum flags in my application. The Enum can have around 50+
values, so values go up to 2^50. I was just wondering, can I use
Math.Pow(2, variable) to calculate these? When I try to do that …