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 / test.html
Created February 6, 2014 02:57
HTML5 + JavaScript Boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
...
<script src="test.js"></script>
</body>
@ProfAvery
ProfAvery / shim.js
Created February 12, 2014 07:13
Shim for running simple Node.js modules with jrunscript
(function(global) {
if (typeof java !== "undefined") {
this.console = { log: function(s) { println(s); } }
// Download from https://raw.github.com/micmath/Rhino-Require/master/src/require.js
load("require.js");
}
}(this));
// Call console.log() and require() as usual
@ProfAvery
ProfAvery / form.html
Last active August 29, 2015 13:56
Form processing example from lecture
<% if (typeof message !== "undefined") { %>
<%= message %>
<% } %>
<form method="POST">
State:
<input type=text name="state"
value="<%= state %>" size=2 maxlength=2>
<input type="submit">
</form>
@ProfAvery
ProfAvery / form.html
Created March 6, 2014 07:00
Connect-ized form processing example with HTTP Basic
<% if (typeof message !== "undefined") { %>
<%= message %>
<% } %>
<form method="POST">
State:
<input type=text name="state"
<% if (typeof state !== "undefined") { %>
value="<%= state %>"
<% } %>
size="2" maxlength="2">
@ProfAvery
ProfAvery / config.yaml
Created September 10, 2014 05:56
Correctly indented config.yaml
message: This is a message defined in the configuration file config.yaml
messageRepetitions: 3
database:
driverClass: org.hsqldb.jdbc.JDBCDriver
user: cpsc476
password: Passw0rd
url: jdbc:hsqldb:hsql://localhost/cpsc476;ifexists=true
@ProfAvery
ProfAvery / genlogs.c
Last active August 29, 2015 14:08
Generate fake log entries to stdout
/* genlogs.c - Generate fake log entries to stdout */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#define DATE_MAX_CHARS 25
#define SIZE(a) (sizeof(a) / sizeof(*(a)))
@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: