How to escape regular expression in javascript? [duplicate]

How to escape regular expression in javascript? [duplicate]

This question already has an answer here: Is there a RegExp.escape function in Javascript? 12 answers I have code like:pattern = 'arrayname[1]'; // fet

PHP does not display error messages

PHP does not display error messages

I installed XAMPP 1.7.4 (with PHP 5.3.5), the problem is PHP does not display any error messages. E.g. if I connect to MYSQL with mysql_connect() without parameters, PHP will not complain about the required fields.Why is this?How can I conf

How do I get the last inserted ID of a MySQL table in PHP?

How do I get the last inserted ID of a MySQL table in PHP?

I have a table into which new data is frequently inserted. I need to get the very last ID of the table. How can I do this?Is it similar to SELECT MAX(id) FROM table? 1:If you're using PDO, use PDO::lastInsertId.If you're using Mysqli, us

Why non-equality check of one variable against many values always returns true?

Why non-equality check of one variable against many values always returns true?

I have a variable v in my program, and it may take any value from the set of values"a", "b", "c", ..., "z"And my goal is to execute some statement only when v is not "x", "y", or "z".I have tried,for C-like languages (where equality operato

How do I watch a file for changes?

How do I watch a file for changes?

I have a log file being written by another process which I want to watch for changes. Each time a change occurs I'd like to read the new data in to do some processing on it.What's the best way to do this? I was hoping there'd be some sort o

Using jQuery to center a DIV on the screen

Using jQuery to center a DIV on the screen

How do I go about setting a

in the center of the screen using jQuery? 1:I like adding functions to jQuery so this function would help:jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(

String literals: Where do they go?

String literals: Where do they go?

I am interested in where string literals get allocated/stored.I did find one intriguing answer here, saying: Defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smar

How to set a value to a file input in HTML?

How to set a value to a file input in HTML?

Note: The answers & comments below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programatically using JavaScript and a dataTransfer or FileList object in 2017.

Efficiently convert rows to columns in sql server

Efficiently convert rows to columns in sql server

I'm looking for an efficient way to convert rows to columns in SQL server, I heard that PIVOT is not very fast, and I need to deal with lot of records.This is my example: ---------------------------- | Id | Value |ColumnName | -----

PHP Script to populate MySQL tables

PHP Script to populate MySQL tables

Is anyone aware of a script/class (preferably in PHP) that would parse a given MySQL table's structure and then fill it with x number of rows of random test data based on the field types? I have never seen or heard of something like this an

CSS - Internet Explorer and the  tag background

CSS - Internet Explorer and the tag background

I have a pretty simple layout which renders fine in both Firefox and Chrome, but Internet Explorer (version 11) seems to be unable to render any kind of background color for the element.I have the element as a child of the element and ne

Does Content Security Policy block bookmarklets?

Does Content Security Policy block bookmarklets?

Does Mozillas CSP block to execute Javascript from a bookmark by default?Can it be configured to do so? 1:As of 2017, the answer is still a definitive "maybe" - just like when this answer was originally posted in 2011. The specification

Python Logging to Tkinter Text Widget

Python Logging to Tkinter Text Widget

Does any one out there have an example of how to setup logging in Python to a Tkinter Text Widget? I have seen this used in several apps but cannot figure out how to direct the logging to anything other than a log file. 1:You should sub

Missing script/generate in Rails 3

Missing script/generate in Rails 3

I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.I have created a new app from scratch with no options to verify.Any idea why thi

How to increment a JavaScript variable using a button press event

How to increment a JavaScript variable using a button press event

Can I create a javascript variable and increment that variable when I press a button (not submit the form).Thanks! 1:Yes:andIncrement 2:The purist way to do this would be to add event handlers to the button, instead of mixing behavior

how to use jQuery installed with npm in Express app?

how to use jQuery installed with npm in Express app?

I have a node.js + express app and I installed jQuery with npm.in the app.js file I usedvar jquery = require('jquery');In the html file header I included javascript that uses jQuery and I get `jQuery is not defined'.Is it a metter of order

Print all variables available in a Smarty template

Print all variables available in a Smarty template

How do you print all variables available in the context of a Smarty template? Something like the Django debug trace that lists everything being passed.Thanks 1:Use {debug} From the manual: {debug} dumps the debug console to the page. T

Powershell: How to initialize array of custom objects?

Powershell: How to initialize array of custom objects?

I'm fairly new to PowerShell, and usually Google or searching forums like these yields the answers I seek - but not this time. So here is my question (generalized from specific task for privacy/security reasons):First, as this leads to my

how to store grep command result in some variable in shell

how to store grep command result in some variable in shell

I want to find out number of directories and files in home directory and want to store count some variable in a shell script. I am using following set of commands.command="ls -l | grep -c \"rahul.*patle\""eval $commandi want to store this c

How to display loading status with preloader and multiple images?

How to display loading status with preloader and multiple images?

I am building a slideshow with a few hundred images and would like to build a nice loading bar, so the idea was to preload the images using JavaScript, then initialize the rest of the UI afterwords.Preloading the images is not a problem, bu

Grails PermGem error

Grails PermGem error

I need help with this problem. I need someone to explain to me why is this happening and how to prevent or avoid it.Exception in thread "Thread-747" java.lang.OutOfMemoryError: PermGen spaceException in thread "Thread-748" java.lang.OutOfMe

Save data to PHP / Mysql with inline edit in CKEditor

Save data to PHP / Mysql with inline edit in CKEditor

I want to use "inline edit" of the new CKEditor 4 (http://docs.ckeditor.com/#!/guide/dev_inline-section-2), but can not find any example of how to save the data with PHP / MySQL.Can you help me? 1:You need some AJAX magic. Via JavaScript

automatic installation of common magento extensions at project kickoff

automatic installation of common magento extensions at project kickoff

There are some Magento Connect extensions that I find myself installing every time I create a new project, such as Fontis_Recaptcha, Mass_Product_Relater, HM_DeveloperToolbar, ModuleCreator, Alanstormdotcom_Layoutviewer, etc. What's on you

Getting the closest date to a given date

Getting the closest date to a given date

Given this base date:base_date = "10/29 06:58 AM"I want to find a tuple within the list that contains the closest date to the base_date, but it must not be an earlier date. list_date = [('10/30 02:18 PM', '-103', '-107'), ('10/30 02:17 PM',

How to Access ViewData in javascript

How to Access ViewData in javascript

I am having a problem accessing the ViewData object through javascript. I have set the ViewData object on the controller and on document.ready event of the view i am trying to see the contents of that same ViewData object like so: var