$string = 'hi there [hello]this is my hello message[/hello][hello]this is another hello message[/hello]';
// Count the number of occurences:
$count = preg_match_all( '/\\[hello\\]/', $string, $dummy );
// Delete [hello] if not closed
// First replace closed matches, then delete remaining, then replace back
$string = preg_replace( '/\\[hello\\](.*)\\[\\/hello\\]/U', '[qwerty]$1[/qwerty]', $string );
$string = str_replace( '[hello]', '', $string );
$string = str_replace( 'qwerty', 'hello', $string );
echo "Count is: $count$string";
?>
Tuesday, September 15, 2009
PHP counting the # of word occurance in a string
How to disable/turn off Visual Studio .NET JIT Debugger
How to disable/turn off Visual Studio .NET JIT Debugger
* How to disable/turn off Visual Studio .NET JIT Debugger
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
If value = 0, prompt the user by means of a message box. The choices are:
Continue. This results in a stack dump and process termination.
Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
*Disabling Visual Studio "Just In time Debugger"
Go to Tools -> Options -> Debugging -> Just-In-Time and disable VS as the JIT debugger.
* How to disable/turn off Visual Studio .NET JIT Debugger
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
If value = 0, prompt the user by means of a message box. The choices are:
Continue. This results in a stack dump and process termination.
Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
*Disabling Visual Studio "Just In time Debugger"
Go to Tools -> Options -> Debugging -> Just-In-Time and disable VS as the JIT debugger.
Wednesday, September 2, 2009
parsing the google trends atom feed rss
$feed = simplexml_load_file('http://www.google.com/trends/hottrends/atom/hourly');
$children = $feed->children('http://www.w3.org/2005/Atom');
$parts = $children->entry;
foreach ($parts as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
$dom = new domDocument();
@$dom->loadHTML($details->content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$url = $anchor->getAttribute('href');
$urltext = $anchor->nodeValue;
echo 'Link: ' . $urltext . ' ';
}
}
Thursday, July 2, 2009
Showing Page Load Time: Asp Classic/VBScript
Page Load Time: Asp Classic/VBScript
Shows the script page load time at the bottom of each ASP page.
At the header of the Page:
<%
dim starttime
startrime = Timer
%>
At the footer of the page:
<%
dim endtime,timetaken
endtime = Timer
timetaken = FormatNumber(endtime - starttime,4)
response.write "page load time: " & timetaken & " seconds"
%>
Sunday, May 10, 2009
Javascript Saving user name and password to a cookie
<html>
<head>
<script language="JavaScript"><!--
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}a
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));
function set() {
if (document.logonForm.elements[1].checked)
Set_Cookie("userid",document.logonForm.userid.value,expires);
if (document.logonForm.elements[3].checked)
Set_Cookie("password",document.logonForm.password.value,expires);
}
function get() {
userid = Get_Cookie("userid")
if (userid != null) {
document.logonForm.userid.value = userid;
document.logonForm.elements[1].checked = true;
}
password = Get_Cookie("password")
if (password != null) {
document.logonForm.password.value = password;
document.logonForm.elements[3].checked = true;
}
}
//--></script>
</head>
<body onLoad="get()">
<form name="logonForm" onSubmit="return set();">
<p>Userid: <input type="input" name="userid"> Save <input type="checkbox">
<p>Password: <input type="password" name="password"> Save <input type="checkbox">
<p><input type="reset"> <input type="submit">
</form>
</body>
</html>
Monday, May 4, 2009
Simple Javascript Page Redirect
<script language="javascript">
document.location='YOUR LINK HERE';
</script>
document.location='YOUR LINK HERE';
</script>
Sunday, April 19, 2009
Javascript Submitting form on pressing the enter key
<html>
<body>
<script language="JavaScript">
function submitonEnter(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == "13"){
document.form1.submit();
}
}
</script>
<form name="form1" action="index.php?mid=72me211v4604" method="POST">
<textarea name="msg" onKeyDown="javascript:return submitonEnter(event);"></textarea>
<br>
<input type="submit" value="Sänd/uppdatera">
</form>
</body>
</html>
<body>
<script language="JavaScript">
function submitonEnter(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == "13"){
document.form1.submit();
}
}
</script>
<form name="form1" action="index.php?mid=72me211v4604" method="POST">
<textarea name="msg" onKeyDown="javascript:return submitonEnter(event);"></textarea>
<br>
<input type="submit" value="Sänd/uppdatera">
</form>
</body>
</html>
Subscribe to:
Posts (Atom)
