Skip to content

Instantly share code, notes, and snippets.

View grahamg's full-sized avatar

Graham Greenfield grahamg

View GitHub Profile
@grahamg
grahamg / .vimrc
Last active October 14, 2016 14:34
Vim Configuration
" Use Vim settings rather than Vi settings
" Required to be at the beginning of file
set nocompatible
" Required
filetype off
" Turn on syntax highlighting
syntax on
#!/usr/bin/python
import os, pwd, grp, subprocess
#Base directory of your django sites
wwwroot = "/var/www/"
#Create list of directories inside wwwroot
dirs = os.listdir(wwwroot)
#Default django project directory
@grahamg
grahamg / maldet_automate.sh
Created February 1, 2012 22:22
Check the progress of a currently running maldet malware session, if not start one up in the background
#!/bin/bash
download_location=http://www.rfxn.com/downloads/maldetect-current.tar.gz
scan_location=/home?/?
maldet=/usr/local/sbin/maldet
dump_file='/root/maldet_$(pidof -x $maldet)_$(date +"%m-%d-%Y-%T").dump'
hash maldet 2>&- || {
echo >&2 "Maldetect not installed. Installing...";
wget --progress=dot $download_location -O /root/maldetect-current.tar.gz
@grahamg
grahamg / find_admin_cpanel.pl
Created July 31, 2011 17:23
Find Admin cPanel
#!/usr/bin/perl
##
# Admin Control Panel Finder v2.1.4
# Home: server@root
##
use HTTP::Request;
use LWP::UserAgent;
@grahamg
grahamg / ftp_backup.sh
Created April 13, 2011 01:54
Backup some selected .tar.gz files to a remote ftp server
#!/bin/bash
FTPU="user" # ftp login name
FTPP="passwd" # ftp password
FTPS="ftp.server.com" # remote ftp server
FTPF="/home/backup/" # remote ftp server directory for $FTPU & $FTPP
LOCALD="backup.$(date +%d.%m.%y).tgz"
ncftpput -m -u $FTPU -p $FTPP $FTPS $FTPF $LOCALD
@grahamg
grahamg / Linux Command Reference
Created April 3, 2011 02:53
A List that I often refer to for useful commands for debugging Linux systems.
Plesk port: 8443
R1Soft CDP port: 1167
cPanel port: WHM over SSL = 2087
cPanel over SSL = 2083
regular WHM = 2086
regular cPanel = 2082
feedback loop information:
http://www.eliteemail.com/features/email-delivery/feedback-loops/
@grahamg
grahamg / CoffeePot.rb
Created March 17, 2011 09:09
CoffeePot example class in Ruby complete with Test::Unit tests.
#!/usr/bin/env ruby
=begin
1) When I create a "CoffeePot" object, it should be empty and I will know this because it returns true when I ask it "coffee_pot.is_empty?", and it tells me 0 when I ask it "coffee_pot.cups_left"
2) When I call the "coffee_pot.fill" method it should change state to have 10 cups left in it, so when I call the "coffee_pot.cups_left" method it returns 10. If I ask "coffee_pot.is_empty?", it should return false.
3) every time I call the "coffee_pot.pour_cup" method, there should be one less cup remaining.
4) if I call "coffee_pot.pour_cup" when the pot is empty, it should raise an exception.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Backbone example</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="underscore.js"></script>
<script type="text/javascript" src="backbone.js"></script>
@grahamg
grahamg / gist:825365
Created February 14, 2011 01:16
Rsync Backup Script
#!/bin/bash
# Destination host machine name
DEST="beta.grahamg.org"
# User that rsync will connect as
# Are you sure that you want to run as root, though?
USER="remote_backup"
# Directory to copy from on the source machine.
#include <stdio.h>
/* BEGIN HACKERY */
typedef struct field {
enum {
TABLE_NAME,
TABLE_FIELD,
TABLE_TERMINATOR
} tag;