Skip to content

Instantly share code, notes, and snippets.

@hamstar
hamstar / gist:1180273
Created August 30, 2011 05:51
UNTESTED simple Oracle SQL procedure that gets a products price, multiplies it by the quantity and adds it to the sales table
/* Add a sale */
CREATE OR REPLACE PROCEDURE add_sale(
v_cust_id customers.id%TYPE,
v_prod_id products.id%TYPE,
v_qty sales.qty%TYPE
)
IS
v_price_single products.price%TYPE;
v_price_total sales.price%TYPE;
BEGIN
@hamstar
hamstar / gist:1180286
Created August 30, 2011 06:00
UNTESTED triggers
/* check that there is enough quantity */
CREATE OR REPLACE TRIGGER check_enough_stock
BEFORE INSERT ON sales
FOR EACH ROW
DECLARE
v_qoh product.qoh%TYPE;
e_not_enough_stock EXCEPTION;
BEGIN
SELECT qoh INTO v_qoh
FROM products
@hamstar
hamstar / bindout.txt
Created September 8, 2011 04:31
Output from bind
[hamstar@behemoth:/etc] ?? dig localdomain.
; <<>> DiG 9.7.3 <<>> localdomain.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 15303
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localdomain. IN A
@hamstar
hamstar / etcbindnamed.conf.local
Created September 8, 2011 05:10
Sample working DNS file
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
// Reverse DNS
zone "0.0.10.in-addr.arpa" {
@hamstar
hamstar / TaskStatus.java
Created September 29, 2011 04:44
Demonstration of a Java ENUM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Enums;
/**
*
* @author fwm8280
@hamstar
hamstar / gist:1260692
Created October 4, 2011 01:12
Factory save method example
class TaskFactory {
public void save( Task task ) {
HashMap data = new HashMap<>();
data.put("Name", task.getName() );
data.put("Description", task.getDescription() );
// etc...
if ( task.isNew() ) {
@hamstar
hamstar / PanelObservable.java
Created October 6, 2011 10:40
Observable extension example
package Helpers;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
/**
* @author Shane van Wyk [GFN5594]
* @author Robert McLeod
* @since 02/10/2011
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.3-p0@captor"
#
# Uncomment following line if you want options to be set only for given project.
@hamstar
hamstar / robbyrussell.zsh-theme
Created January 4, 2012 03:28
Custom zsh theme made from robbyrussell.zsh-theme
PROMPT='%{$fg_bold[red]%}➜ %n%{$fg_bold[white]%}@%{$fg_bold[green]%}%m%{$fg_bold[white]%}:%{$fg[cyan]%}%/ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@hamstar
hamstar / Event.php
Created February 9, 2012 04:59
SuperModel/Model setup
<?php
class EventNotFoundException extends Exception{};
class Event extends SuperModel {
protected $TABLE = 'event';
protected $db_fields;