Skip to content

Instantly share code, notes, and snippets.

View ProfAvery's full-sized avatar

Kenytt Avery ProfAvery

  • California State University, Fullerton
  • Fullerton, CA
View GitHub Profile
@ProfAvery
ProfAvery / sum.rb
Created February 9, 2012 05:39
15 ways to sum an array in Ruby
#!/usr/bin/env ruby
require 'test/unit'
class TestSums < Test::Unit::TestCase
def setup
@a = [2, 5, 18, 27]
@sum = 0
end
@ProfAvery
ProfAvery / shorten.rb
Created February 9, 2012 07:09
Crazy Eddie's Discount URL Shortener
#!/usr/bin/env ruby
require 'sinatra'
require 'redis'
require 'enumerator'
configure do
REDIS = Redis.new
REDIS.setnx 'next', 10 * 36 ** 3
end
@ProfAvery
ProfAvery / image_upload.rb
Created February 9, 2012 07:13
Storing pictures in Redis
#!/usr/bin/env ruby
require 'sinatra'
require 'redis'
configure do
REDIS = Redis.new
end
get '/' do
@ProfAvery
ProfAvery / hello.erb
Created February 9, 2012 07:17
Hello World in Sinatra
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Hi, tell us a little about yourself</h1>
<form method="POST" action="/response">
<p>
Name: <input type="text" name="name" />
$ rvm use 1.9.2@railstutorial
$ rails new movies
$ cd movies
$ bundle install --local
$ rails generate scaffold Movie title:string rated:string
$ rails generate scaffold Category name:string
$ rails generate migration create_categories_movies
db/migrate/*_create_categories_movies.rb:
#!/usr/bin/env ruby
require 'sinatra'
require 'redis'
configure do
REDIS = Redis.new
end
get '/' do
@ProfAvery
ProfAvery / create-text-archive.js
Created September 12, 2012 01:07
jrunscript utilities
var createTextArchive = (function() {
var root;
function enumerate(e, callback) {
while (e.hasMoreElements()) {
callback(e.nextElement());
}
}
@ProfAvery
ProfAvery / Spring Configuration Quick Reference
Last active October 11, 2015 01:17
Spring Configuration Quick Reference
XML NAMESPACES
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!--Bean declarations go here-->
#!/bin/sh
$HOME/google_appengine/dev_appserver.py \
--address=0.0.0.0 \
--high_replication \
--use_sqlite \
$*
@ProfAvery
ProfAvery / .SciTEUser.properties
Created February 21, 2013 07:57
Settings for Python programming with SciTE
tab.size=4
indent.size=4
use.tabs=0
tab.indents=1
backspace.unindents=1