Skip to content

Instantly share code, notes, and snippets.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldnetworkname.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.oldnetworkname.com$
RewriteRule (.*)$ http://newname.com/$1 [R=301,L]
// turn gravity form labels into placeholder values
jQuery('form ul li').each(function(index) {
feildid = jQuery(this).attr('id');
feildname = jQuery('#'+feildid+' label').text().replace('*','').replace(':','');
jQuery('#'+feildid+' input, #'+feildid+' textarea').attr('placeholder',feildname);
jQuery('#'+feildid+' label').remove()
})
$ sudo vi /etc/apache2/users/handsomefox.conf
<Directory "/Users/handsomefox/Sites/">
Options Indexes MultiViews
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
* * * * * top -d 99 -n 1 -b > /var/www/.../top.txt
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
// reload #dynamic_stats of this page every 30 seconds
// this will hold and change the results of top
// stored in spans: #source_*
// which is read by the gauges outside of #dynamic_stats
$(document).ready(function() {
setInterval(function() {
var url = 'http://.../this_file.php';
$('#dynamic_stats-wrapper').load(url + ' #dynamic_stats');
<div id="dynamic_stats-wrapper">
<!-- Everything below reloads every 60 seconds -->
<div id="dynamic_stats">
<?
// get the file from the server
$stats = file_get_contents('/var/www/.../top.txt');
$cores = 16;
// checky amature way to remove extra spacing
<?
$mysqli = new mysqli('localhost', 'user', 'password', 'database');
$handle = fopen('filename.sql', 'rb');
if ($handle) {
while (!feof($handle)) {
// This assumes you don't have a row that is > 1MB (5000000)
// which is unlikely given the size of your DB
// Note that it has a DIRECT effect on your scripts memory
$buffer = stream_get_line($handle, 5000000, ";\n");
$mysqli->query($buffer);