Wednesday, 29 November 2017

regex - How can a recursive regexp be implemented in python?

I'm interested how can be implemented recursive regexp
matching in Python (I've not found any examples :( ). For example how would one write
expression which matches "bracket balanced" string like
"foo(bar(bar(foo)))(foo1)bar1"

mysql - PHP MySQLi doesn't execute INSERT query

I had a false redirect. But the system won't
let me delete the question

I have a website with a register
page. In the backend is a SQL database, but while UPDATE and SELECT work, INSERT
doesn't. IT also doesn't give me any errors.



The
code which makes the INSERT statement looks as
follows:



$username =
"peter";
$pwhash = password_hash($password,
PASSWORD_DEFAULT);

$role = "publisher";
$locked =
"false";

//Prepare SQL Query
$sql = "insert into
user(username, password, role, locked)";
$sql .= " VALUES (?, ?, ?,
?);";

//Reuire SQL Connection
require
"db_inc.php";

//Prepare stmt
$stmt = mysqli_prepare($con,
$sql);

//Bind Parameters
mysqli_stmt_bind_param($stmt,
'ssss',
$username,
$pwhash,
$role,

$locked);

//Execute
SQL
mysqli_stmt_execute($stmt);


mysqli_close($con);


The
SQL database looks like this:
rel="nofollow noreferrer">SQL<br />            Database



What am I doing wrong?
The $con connection is correct, as it workes on the SELECT and UPDATE
querys.

html - Go to another site automatically





How can I make a Web page that takes me automatically without
clicking to another site? (I use in HTML)



I
tried to find a answer but I didn't find any answer that it in
HTML.



I tried to write like
this:



data-hide="false" data-console="true" data-babel="false">
class="snippet-code">
            href="http://www.boutell.com/newfaq/">






but this not take me automatically.

can someone help
me?
thanks!


itemprop="text">
class="normal">Answer



Write this
in the head section of the HTML
document.



            http-equiv="refresh" content="0; url=randomname.com"
/>


As soon as the
page loads, on 0 seconds, you can go to your page.



javascript - Converting an object to a string

How can I convert a JavaScript object into a
string?



Example:



var
o = {a:1, b:2}
console.log(o)
console.log('Item: ' +
o)



Output:





Object { a=1, b=2} // very nice readable output :)
Item: [object
Object] // no idea what's inside
:(


sublimetext2 - Oniguruma Regex - Match entire group content and not just the last occurrence

I'm writing a syntax highlighter for the Sublime Text
editor (that uses the Oniguruma regex definitions). Basically, I have something like
this:




Regex:
\((\w+\s*)*\)



Test:
(how
are you)



Capturing
groups:
1.
you



My problem is, that only the
last occurrence in the capturing group is matched (and therefore highlighted) and not
the entire content of the capturing
group.




In my concrete
case:



Regex:
\(\w+(\s+(\?\w+\s+)+-\s+(\w+))*\)



Test:
(at
?l - location ?x -
object)



Capturing
groups:




1. ?x -
object
2. ?x
3.
object


However, I'd
like to match the entire group content, like
that:



1. ?x - object AND ?l -
location
2. ?x AND ?l

3. object AND
location

javascript - Animate width to fit-content

I need to animate a div from a
width of 0 (initial) to a width
fit-content (a width that is the same as the width of its
content)



$('div').css('width',
'fit-content');



href="https://jsfiddle.net/yzugzf3h/1/" rel="nofollow
noreferrer">DEMO



However, if I do
this the animation



transition:
width .5s
ease-in-out;


doesn't
work anymore. So the question is how can I animate just to fit the content
?




UPDATE: I found the solution href="https://stackoverflow.com/questions/3508605/how-can-i-transition-height-0-to-height-auto-using-css">here
(DEMO

c - How do I use extern to share variables between source files?

I know that global variables in C sometimes have the
extern keyword. What is an extern
variable? What is the declaration like? What is its
scope?



This is related to sharing variables
across source files, but how does that work precisely? Where do I use
extern?

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...