Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Nicholas http://organanddrums.net

tar syntax

// tar:
tar -cvzf file.tar.gz inputfile1 inputfile2


// untar:
tar -xvzf file.tar.gz

Reset mysql password to old style

SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');

Load external file into div

// javascript to go into head of document or external .js file

function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
	ahah(name,div);
	return false;
}


// call code with the name of the external file and the id of the div you want to put the content into

<a href="file1.html" onclick="load('file1.html','content');return false;">File 1</a>

Open Firefox in Safe Mode

// opens Firefox with extensions disabled. Also gives you the ability/option to reset Firefox to defaults.

// More info and code for other platforms can be found at http://kb.mozillazine.org/Safe_mode

/Applications/Firefox.app/Contents/MacOS/firefox -safe-mode

Change root password in OS X Server

In Terminal:

passwd root

Change admin password in OS X Server

Bad things can happen if you change the administrator password on OS X server the wrong way. The right way is to change it via Workgroup Manager (NOT System Preferences) or via this command in Terminal:

passwd admin

Flush DNS cache

In Terminal, type:

lookupd -flushcache

Change Default Screen Capture Format in OS X

Enter the following into Terminal:

defaults write com.apple.screencapture type *format*


In place of *format* in the above put any of the following, depending on your preference:

jpg
pdf
tif
png - this is the default

(There may be others. Feel free to add these to the comments.)