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
function Question(questionType, questionText, questionChoices, questionAnswers, answers){
this.questionType = questionType;
this.questionText = questionText;
this.questionChoices = questionChoices.split("|");
this.questionAnswers = questionAnswers.split(",");
this.answers = answers;
}
#
# Basic Ruby script to create a new project for basic web development
#
# Author: David Duggins
# Email: [email protected]
#
# Created: 5/4/2010
# License: GPL2
#
@contentsArray=[] #first we initialize an array for the contents
@fileArray =[] #then we initialize an array for the files
Dir.foreach("#{RAILS_ROOT}/public/posts") do |fname|
next if fname == '.' or fname == '..'
@fileArray.push fname
end
@fileArray = @fileArray.reverse #this insures that the blogs entries are listed in descending order
@fileArray.each{|file|
f = File.open("#{RAILS_ROOT}/public/posts/" + file, 'r')
function Car(make, model, carColor){
this.make = make;
this.model = model;
this.carColor = carColor;
alert("Smell That New Car Smell!");
}
Car.prototype.make = 'Car Make';
Car.prototype.model = 'Car Model';
Car.prototype.carColor = 'Car Color';
require 'rss'
require 'open-uri'
@contentArray = []
rss = RSS::Parser.parse open('http://weatheredwatcher.posterous.com/rss.xml').read, false
puts rss.channel.title
rss.items.each_with_index do |item,i|
puts "" if i.zero? or item.date.day != rss.items[i-1].date.day
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
class Pizza
def initialize(&factory)
@factory = factory
end
def bake
@factory.call
end
end
@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];
#!/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 / 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