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 / 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 / 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 / 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 / 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 / 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 / zf..sh
Created February 26, 2013 18:44
a really basic shell script to initiate a Zend Framework 2 Skeleton Application
#!/bin/sh
#
if [ -n "$1" ];
then
git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive $1
else
echo "no project given"
@weatheredwatcher
weatheredwatcher / lithifyme.sh
Created September 19, 2013 20:15
Here is a basic shell script to create a new project based on lithium. Download then type: `sudo mv lithifyme.sh /usr/local/bin/lithifyme` or place it somewhere in your PATH so that you can execute it globally.
#!/bin/bash
# Lithifyme script.
# Creates a new project based on lithium.
# @Author David Duggins [[email protected]]
# Released under the GPLv3
if [ ! -d "$1" ]; then
git clone git://github.com/UnionOfRAD/framework.git $1
echo "initializing submodules"
cd $1
@weatheredwatcher
weatheredwatcher / bat_test.sh
Created December 1, 2013 23:15
I found this script on the i3 forums and thought that I'd share it from here. It's a cool little script that checks for battery strength and warns you via the nagbar if your battery is running low. Helpful if you run the i3 status bar on the bottom and don't always notice if the battery is low!!
! /bin/bash
SLEEP_TIME=5 # Default time between checks.
SAFE_PERCENT=30 # Still safe at this level.
DANGER_PERCENT=15 # Warn when battery at this level.
CRITICAL_PERCENT=5 # Hibernate when battery at this level.
NAGBAR_PID=0
export DISPLAY=:0.0
@weatheredwatcher
weatheredwatcher / beerme.rb
Created December 5, 2013 04:09
This is a ruby snippet I use in a TextMate Bundle for Hipster Ipsum
#!/usr/bin/ruby
require 'open-uri'
require 'json'
url = 'http://hipsterjesus.com/api?paras=1'
buffer = open(url, "UserAgent" => "Ruby-Wget").read
# convert JSON data into a hash
@weatheredwatcher
weatheredwatcher / vhost_writer.py
Last active November 15, 2023 16:16
A python script for creating vhost files
#!/usr/bin/python
import sys, getopt
def main(argv):
server = ''
path = ''
try:
opts, args = getopt.getopt(argv, "hs:p:", ["server=", "path="] )