ASP.Net 301 Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!
you get a message something like:
-bash: mysqldump: command not found
so how do you fix this? well, copy and paste the following into your terminal window and press enter:
echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile
source ~/.profile
whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.
If you want to undo it, you can always edit your .profile, or just delete it.
If an “unable to connect to database” comes up while installing WordPress on a Snow Leopard machine, try adding :3306 to the end of the DB_HOST in wp-config.php
Assuming everything else works, this should solve your problem!
//tell javascript to run a function in 1 second
setTimeout ("myFunction()", 1000 );
function myFunction(){
//do stuff
//once the function is finished, queue this function up to run again in 1 second
setTimeout ( "myFunction()", 1000 );
}
Google doesn’t make it easy to show you the latitude and longitude of an address you search in google maps, but there’s an easy way to get the info.
javascript:void(prompt('',gApplication.getMap().getCenter())); into the address barTo enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:
Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all
if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:
Options FollowSymLinks
AllowOverride All AuthConfig
So for work, the designer says “Hey, can we use this font in the webpage” and like an idiot, I say “sure, why not?”. Well, FF and Safari don’t support .otf files (for whatever reason) So I download FontForge, open it in X11 (on my mac) and convert it to .ttf, which works great.
Then I messed around in IE, trying to make it work, even downloading this tool:
Worst thing EVER. Don’t do this. Don’t get this. Don’t even look at this. You will feel violated if you use it.
So…how to embed an OTF font in a website (make sure you have a license to do so kids):
Have a nice day
While designing a recent WordPress plug-in for TruthMedia that was designed to follow MVC, I had an awful lot of database work to do, and it needed to all be properly secured, which was a lot of work, and while making a rather large change to the way the database worked, I realized that writing all the db code by hand was crazy inefficient.
So I wrote a class that you can extend with any model class of your own, and it will automatically have create, read, update, and delete functionality with no more work required. It also uses all of the WordPress security features to properly escape everything and prevent injection. Although, if you can crack it I’d love to hear from you!
This is how it works:
In your class, extend the class name, so for example:
class person extends wec_db {
var $ID;
var $FirstName;
function __construct($id = null, $autoload = true){
//If we are given an ID
if(!empty($eventID)){
$this->setID($eventID);
if($autoPopulate){
$this->read();
}
}
}
//getters and setters, and any other methods for this object
}
Setup Note: to keep your plugin from stepping on the toes of others, make sure you change the prefix at the top of the class. Also, changing the name of the class to (plugin prefix)db (example:wec_db) will make sure that it doesn’t interfere with anyone else’s if they’re using this class!
Usage:
Create / Add
$person = new person();
$person->setFirstName(‘Joe’);
$person->setLastName(‘Blow’);
$person->add();
Read
$person = new person($personID);
Update
$person = new person($personID);
–or–
$person = new person($personID, false);
$person->setFirstName(‘Jane’);
$person->update();
Delete
$person = new person($personID, false);
$person->delete();
Post any questions in the comments! I’d love to hear from you!
So, wouldn’t it be user friendly, if when you went to a form page in a document, if the cursor was automagically positioned at the first field in the form?
Why, yes it would. Try:
Event.observe(window, 'load', function(){
try {
$('eventName').focus();
}
catch (e) {}
});
after your </form> tag. This requires the prototype javascript library
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function duplicateField(field1, field2){
var theLength = document.getElementById(field1).value.length - 1;
var theString = document.getElementById(field1).value;
for(var i=0; i < theString.length-1; i++){
if(theString.charAt(i) == " "){
theString = setCharAt(theString, i, "_");
}
}
document.getElementById(field2).style.color = "#c9c9c9";
document.getElementById(field2).value = theString;
}
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1);
}
function changeColorBack(fieldName){
document.getElementById(fieldName).style.color = "#000000";
}
</script>
</head>
<body>
<p>
<input id="field1" onkeyup="duplicateField('field1', 'field2');" type="text" />
</p>
<p><br />
<input id="field2" type="text" onfocus="changeColorBack('field2');" /><br />
</p>
<p>
<span id="span1"></span>
<input id="submitButton" type="submit" value="Submit" />
</p>
</body>
</html>