Skip to content

Instantly share code, notes, and snippets.

View weatheredwatcher's full-sized avatar
:octocat:
Working from home

David Duggins weatheredwatcher

:octocat:
Working from home
View GitHub Profile
@weatheredwatcher
weatheredwatcher / base.pp
Created February 4, 2013 03:48
Here is a base puppet script that installs Zend Community Server on Red Hat/Cent OS/Fedora. To make this work for a Debian based server, you really just need to modify the repos class to write a apt source file. We also shut down iptables only because this is a provisioning script for a Vagrant box and iptables interferes with port-forwarding
# Lets tell Puppet the order of our stages
stage {
'users': before => Stage['repos'];
'repos': before => Stage['packages'];
'packages': before => Stage['configure'];
'configure': before => Stage['services'];
'services': before => Stage['main'];
}
@weatheredwatcher
weatheredwatcher / blog.php
Created November 15, 2012 21:22
How to Build a Blog in 15 Minutes (using Codeigniter)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
@weatheredwatcher
weatheredwatcher / regex_test.php
Created October 8, 2012 17:17
A basic test for regular expressions
function isTable($string) {
if (preg_match("/^cms_/i", $string)) { //this is where you place the regex that you want to test
return TRUE;
} else {
return FALSE;
}
}
$string= ["cms_phone_apps", "cms_phone", "cms phone", "phone_cms"]; //using php 5.4's new array syntax rocks!
@weatheredwatcher
weatheredwatcher / rip_site.py
Created June 16, 2012 01:31
Simple script that I wrote that utilizes wget to rip a site onto your computer
#!/usr/bin/env python
# file: rip_site.py
import sys
import os
domain = sys.argv[1]
path = sys.argv[2]
os.system ('wget --recursive --no-clobber -- page-requisites --html-extension --convert-links --restrict-file-names=windows --domains ' + domain + ' --no-parent ' + path)
@weatheredwatcher
weatheredwatcher / person.c
Created January 25, 2012 21:25
Create a person...a fun little coding with my daughter
#include <iostream>
#include <string>
using namespace std;
struct person_t {
string name;
int age;
} mine, yours;
@weatheredwatcher
weatheredwatcher / brypt_helper.php
Created January 22, 2012 04:04
A Codeigniter helper for encrypting a string (like a password) using blowfish
<?php
function bcrypt($password, $salt)
{
//Checks to see if blowfish is installed on the server
CRYPT_BLOWFISH or die ('No Blowfish found.');
$password = $password;
$salt = $salt;
//This sets up the Blowfish prefix and end
$Blowfish_Pre = '$2a$05$'; //this instructs blowfish to encrypt 5 passes
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
puts 'parsing xml file'
parsed = Nokogiri::XML(open("./wordpress.2010-10-06.xml"))
puts 'pulling titles'
i = 0
@weatheredwatcher
weatheredwatcher / alere.php
Created April 13, 2011 21:48
puts alere survey results into alere dataset
<?php
require_once('includes/db.inc.php');
$results = mysql_query('SELECT ID, Alere_PID FROM qcl.alere');
while($row = mysql_fetch_assoc($results)){
$current_pid = $row['Alere_PID'];
$pid_results = mysql_query("SELECT Question, Answer FROM qcl.alere_results WHERE PID = '$current_pid'");
while($pid_row = mysql_fetch_row($pid_results)){
$question = $pid_row[0];
class Pizza
def initialize(&factory)
@factory = factory
end
def bake
@factory.call
end
end
class GetLastFmFeed
def self.displayFeed
require 'rss'
require 'open-uri'
@lastfmArray = []
rss = RSS::Parser.parse open('http://ws.audioscrobbler.com/1.0/user/minasmir/recenttracks.rss').read, false
puts rss.channel.title