My html:
<script type="text/javascript">
$(function() {
$("#bt1").click(function() {
var f = $("#form1");
var formData = f.serialize();
alert(formData);
});
});
</script>
<div id="div1">
<form id="form1" action="/Home/Test1" method="post" name="down">
<div id="div2">
<input id="input1" type="text" value="2" />
</div>
</form>
</div>
<input type="submit" id="bt1" />
When I fire up the click event, formData is empty. I'm using jQuery 1.4.2.
Some people using look-alike Unicode symbols to replace English characters to test the internationalization, e.g. "Test" is replaced as "Test". Is there a wellknown name for this language/culture? Are there utils, keyboard layouts, translation tools for this "language"?
In the code below, Pages is defined as
public SortedDictionary<DateTime, float[]> Pages { get; set; }
I am trying to dynamically increase the size of this array. Can anyone tell how to increase the sized of the innermost float[]?
var tt = currentContainer.Pages[dateTime];
Array.Resize<float>(ref tt, currentContainer.Pages.Count + 1);
Fail 1
I tried the following code and get index out of range exception
SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>();
float[] xx = new float[1];
xx[0] = 1;
DateTime tempTime = DateTime.UtcNow;
Pages.Add(tempTime, xx);
var tt = Pages[tempTime];
Array.Resize<float>(ref tt, Pages.Count + 1);
Pages[tempTime][1] = 2;
Fail 2
The following gives a compile time error (property, index, or dynamic member can't be used as a ref value)
SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>();
float[] xx = new float[1];
xx[0] = 1;
DateTime tempTime = DateTime.UtcNow;
Pages.Add(tempTime, xx);
var tt = Pages[tempTime];
// The line below is different from Fail 1 above ... compile time error
Array.Resize<float>(ref Pages[tempTime], Pages.Count + 1);
Pages[tempTime][1] = 2;
Question
What is the most performant answer to resize this array?
Would the answer change if it's likely that the final size will be 100-200 floats or 700-900 floats?
What if I change my allocation size from +1 to +128? .. or larger?
I am writing a app in .NET which will generate random text based on some input. So if I have text like "I love your {lovely|nice|great} dress" I want to choose randomly from lovely/nice/great and use that in text. Any suggestions in C# or VB.NET are welcome.
I have a lotus view that stores a number. I need to perform some math against the value, but I am having a lot of problems getting the types to match up.
doc.numOfGold = numGold
and CInt(doc.numOfGold) = numGold
and CInt(doc.numOfGold) = CInt(numGold)
and doc.numOfGold = CInt(numGold)
all return type mismatch. I've tried changing the column properties to treat it as a decimal, with no better luck.
Any thoughts?
Thanks!
I need to check if a key exists and return its value if it does.
Key can be an array with subkeys or endkey with a value.
$_SESSION['mainKey']['testkey'] = 'value';
var_dump(doesKeyExist('testkey'));
function doesKeyExist($where) {
$parts = explode('/',$where);
$str = '';
for($i = 0,$len = count($parts);$i<$len;$i++) {
$str .= '[\''. $parts[$i] .'\']';
}
$keycheck = '$_SESSION[\'mainKey\']' . $str;
if (isset(${$keycheck})) {
return ${$keycheck};
}
// isset($keycheck) = true, as its non-empty. actual content is not checked
// isset(${$keycheck}) = false, but should be true. ${$var} forces a evaluate content
// isset($_SESSION['mainKey']['testkey']) = true
}
What am I doing wrong ?
Using PHP 5.3.3.
The conversion of a char data type to a DateTime data type resulted in an out-of-range DateTime value.
The statement has been terminated.
Please give me most possible answers
ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id]
@Employee_id int,
@AtDate datetime,
@FNLogged bit,
@ANLogged bit,
@LogTime varchar(10),
@LogOuttime varchar(10)
AS
BEGIN
SET NOCOUNT ON;
update Mst_Attendance set FNLogged=@FNLogged,
ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime
where EmployeeId=@Employee_id and Atdate= @AtDate
END
I have a php variable that comes from a form that needs tidying up. I hope you can help.
The variable contains a list of items (possibly two or three word items with a space in between words).
I want to convert it to a comma separated list with no superfluous white space. I want the divisions to fall only at commas, semi-colons or new-lines. Blank cannot be an item.
Here's a comprehensive example (with a deliberately messy input):
Variable In: "dog, cat ,car,tea pot,, ,,, ;;(++NEW LINE++)fly, cake"
Variable Out "dog,cat,car,tea pot,fly,cake"
Can anyone help?
Hi. First I have to say: Happy Christmas to All!
I'm starting learning classes in PHP. I coded that:
class User {
function getFbId($authtoken) {
}
function getFbFirstName ($authtoken) {
}
}
What I want to do is something like that: $user=new User($authtoken); And pass the $authtoken to the class. It's possible to define that when starting the class. It's possible to retrive that value inside a function of that class?
I'm having a coloumn name with varchar field that holds some folder path like "C:\Program Files\Internet Explorer\en-US" .I need to update the root folder name(Program files to profilesNew).Can anyone please help.
I tried with a query
declare @val as varchar(100)
set @val='C:\Program Files\Internet Explorer\en-US'
select substring(@val,charindex(':\',@val),charindex('\',@val))
but not getting the exact answer
C:\Program FilesNew\Internet Explorer\en-US
I'm trying to print strings in one line.
I've found solutions but they don't works with windows correctly.
I have text file contains names and I want to print them like this
name=john then change john to next name and keep name=, I've made this code but didn't work correctly with windows:
op = open('names.txt','r')
print 'name=',
for i in op.readlines():
print '\r'+i.strip('\n')
thank you for your time
Note: I have read all of the related PHP, UTF-8, character encoding articles that are usually suggested, but my question relates to data inserted before I applied such techniques. I am wishing to retrospectively fix all character encoding problems.
Now all connections are set as utf8 using PDO.
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
Unfortunately, a large amount of data was inserted that is of questionable encoding before I had implemented correct character encoding practices. As displayed by:
$sql = "SELECT name FROM data LIMIT 3";
foreach ($pdo->query($sql) as $row)
{
$name = $row['name'];
echo $name . "\n";
echo utf8_encode($name) . "\n";
echo utf8_decode($name) . "\n";
echo htmlspecialchars($name, ENT_QUOTES, 'UTF-8') . "\n";
echo htmlspecialchars(utf8_encode($name), ENT_QUOTES, 'UTF-8') . "\n";
echo htmlspecialchars(utf8_decode($name), ENT_QUOTES, 'UTF-8') . "\n";
echo '<hr/>';
}
Which produces:
AntonÃÂn Dvořák
AntonÃÆÃÂn DvoÃâ¦Ãâ¢ÃÆÃ¡k
Anton??n Dvo??????¡k
AntonÃÂn Dvořák
AntonÃÆÃÂn DvoÃâ¦Ãâ¢ÃÆÃ¡k
----------
Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶
ñÃâ¬Ã¡Ã´ ýáùáÿÃâ¬ÃµÃ¡Ã¶
????? ??????????
Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶
ñÃâ¬Ã¡Ã´ ýáùáÿÃâ¬ÃµÃ¡Ã¶
----------
Tiësto
Tiësto
Tiësto
Tiësto
Tiësto
Tiësto
----------
When removing 'SET NAMES utf8' with PDO it produces the data:
AntonÃn DvoÅák
AntonÃÂn DvoÃÂák
Antonín Dvorák
AntonÃn DvoÅák
AntonÃÂn DvoÃÂák
Antonín Dvorák
----------
???? ?????????
Ô±ÖÕ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿ÖÕµÕ¡Õ¶
???? ?????????
???? ?????????
Ô±ÖÕ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿ÖÕµÕ¡Õ¶
???? ?????????
----------
Tiësto
Tiësto
Ti?sto
Tiësto
Tiësto
----------
And here is a dump of the database rows concerned:
DROP TABLE IF EXISTS `data`;
CREATE TABLE IF NOT EXISTS `data` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`(10)),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;
INSERT INTO `data` (`id`, `name`) VALUES (0, 'AntonÃÂn Dvořák'), (1, 'Ô±Ö€Õ¡Õ´ Ô½Õ¡Õ¹Õ¡Õ¿Ö€ÕµÕ¡Õ¶'), (2, 'Tiësto');
The 3rd and 6th lines of the 3rd row "Tiësto" are then correctly echoed. I'm just unsure what is the best way to correct encodings/detect the encodings of bad strings and correct, etc.
i'm wondering why doesn't this work ?
it gives me the exception that the "File Format Is Not Valid"
richTextBoxPrintCtrl1.Rtf = richTextBoxPrintCtrl2.Rtf.Insert(richTextBoxPrintCtrl1.SelectionStart, myString);
Hi everyone
I want to make a quiz, I want to have to output an array of questions after a form is submitted.
I know to use a bean I think but how would I do this?
Thanks
I have an array, like
var acronyms = {
'NAS': 'Nunc ac sagittis',
'MTCP': 'Morbi tempor congue porta'
};
I need to find first match of each acronym and wrap around with tag via jQuery.
E.g.
<div id="wrap">NAS dui pellentesque pretium augue. MTCP pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div>
becomes
<div id="wrap"><acronym title="Nunc ac sagittis">NAS</acronym> dui pellentesque pretium augue. <acronym title="Morbi tempor congue porta">MTCP</acronym> pellentesque pretium augue. NAS ac ornare lectus MTCP nec.</div>
Thanks.
Strings in JavaScript are immutable. Across the web and here on Stack Overflow as well, I came across the Array approach to concatenate strings:
var a = [];
a.push(arg1,arg,2....);
console.log(a.join(''));
I know that this approach is better than the simple
console.log(arg1 + arg2 +.....);
for reasons of skipping creating intermediate objects but how does it fair better against :
arg1.concat(arg2,arg3.....);
I am trying to add a .html suffix at the end of all strings supplied by the user before it is entered into the database. Here's my code so far:
strtolower(str_replace(" ", "_", $postTitle));
The above takes the title of the post the user it trying to make, turns it to lower case, replaces all white spaces with underscores and makes it ready to be entered into a database column called post_url.
I just need it to do one more thing and that's to add a .html at the end of each post url. What is the function to do this?
My send mail task works fine for email ids like [email protected] but it throws error for email ids like [email protected].
is there any way i can make it work for such ids also?
Thanks.
In actionscript an object's property can be accesses in this way:
object["propertyname"]
Is something like this possible in c#, without using reflection?
how do you append an additional url parameter to a link in your google search results? is it possible to do this within the style sheet?
for example i have domain.com/result.htm - i want to change the link to domain.com/result.htm?param=1
thank you
I've been using C++ for quite a long time now but nevertheless I tend to fall back on scanf when I have to parse simple text files. For example given a config like this (also assuming that the order of the fields could vary):
foo: [3 4 5]
baz: 3.0
I would write something like:
char line[SOME_SIZE];
while (fgets(line, SOME_SIZE, file)) {
int x, y, z;
if (3 == sscanf(line, "foo: [%d %d %d]", &x, &y, &z)) {
continue;
}
float w;
if (1 == sscanf(line, "baz: %f", &w)) {
continue;
}
}
What's the most concise way to achieve this in C++? Whenever I try I end up with a lot of scaffolding code.
Could someone take a look at this code and find out what's wrong with it?
#!/bin/sh
while :
do
echo " Select one of the following options:"
echo " d or D) Display today's date and time"
echo " l or L) List the contents of the present working directory"
echo " w or W) See who is logged in"
echo " p or P) Print the present working directory"
echo " a or A) List the contents of a specified directory"
echo " b or B) Create a backup copy of an ordinary file"
echo " q or Q) Quit this program"
echo " Enter your option and hit <Enter>: \c"
read option
case "$option" in
d|D) date
;;
l|L) ls $PWD
;;
w|w) who
;;
p|P) pwd
;;
a|A) echo "Please specify the directory and hit <Enter>: \c"
read directory
if [ "$directory = "q" -o "Q" ]
then
exit 0
fi
while [ ! -d "$directory" ]
do
echo "Usage: "$directory" must be a directory."
echo "Re-enter the directory and hit <Enter>: \c"
read directory
if [ "$directory" = "q" -o "Q" ]
then
exit 0
fi
done
printf ls "$directory"
;;
b|B) echo "Please specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
fi
while [ ! -f "$file" ]
do
echo "Usage: \"$file\" must be an ordinary file."
echo "Re-enter the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
fi
done
cp "$file" "$file.bkup"
;;
q|Q) exit 0
;;
esac
echo
done
exit 0
There are some syntax errors that I can't figure out. However I should note that on this unix system echo -e doesn't work (don't ask me why I don't know and I don't have any sort of permissions to change it and even if I wouldn't be allowed to)
Bash Shell Scripting Error: "./myDemo ./myDemo: line 62: syntax error near unexpected token done' ./myDemo: line 62: " [Edited]
EDIT: I fixed the while statement error, however now when I run the
script some things still aren't
working correctly.
It seems that in the b|B) switch statement
cp $file $file.bkup doesn't
actually copy the file to file.bkup ?
In the a|A) switch statement
ls "$directory" doesn't print the directory listing for the user to see
?
#!/bin/bash
while $TRUE
do
echo " Select one of the following options:"
echo " d or D) Display today's date and time"
echo " l or L) List the contents of the present working directory"
echo " w or W) See who is logged in"
echo " p or P) Print the present working directory"
echo " a or A) List the contents of a specified directory"
echo " b or B) Create a backup copy of an ordinary file"
echo " q or Q) Quit this program"
echo " Enter your option and hit <Enter>: \c"
read option
case "$option" in
d|D) date
;;
l|L) ls pwd
;;
w|w) who
;;
p|P) pwd
;;
a|A) echo "Please specify the directory and hit <Enter>: \c"
read directory
if [ ! -d "$directory" ]
then
while [ ! -d "$directory" ]
do
echo "Usage: "$directory" must be a directory."
echo "Specify the directory and hit <Enter>: \c"
read directory
if [ "$directory" = "q" -o "Q" ]
then
exit 0
elif [ -d "$directory" ]
then
ls "$directory"
else
continue
fi
done
fi
;;
b|B) echo "Specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ ! -f "$file" ]
then
while [ ! -f "$file" ]
do
echo "Usage: "$file" must be an ordinary file."
echo "Specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "Q" ]
then
exit 0
elif [ -f "$file" ]
then
cp $file $file.bkup
fi
done
fi
;;
q|Q) exit 0
;;
esac
echo
done
exit 0
Another thing... is there an editor that I can use to auto-parse code? I.e something similar to NetBeans?
Hi my question
Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word.
Given text : "Twenty-three"
The main trick : content having some html tags etc .. tags need to keep that tag with this content only . need to display the words from 10before - 10after
content is bellow :
removed
Thank you
Dear all,
I'm a newbie in bash and I would like to pass as parameter to a python function all files in a directory that don't match a given pattern. sth. like:
$myscripts/myprog.py $myfiles/!(bonjovi)
The above example should retrieve all files that don't match to "bonjovi".
Best wishes