Skip to content

Instantly share code, notes, and snippets.

View LBRapid's full-sized avatar
🏠
Working from home

John Dyer LBRapid

🏠
Working from home
View GitHub Profile
@LBRapid
LBRapid / MountainCipher.java
Created April 18, 2009 02:28
Simple Mountain Cipher encryption of a plaintext file
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class MountainCipher
{
private int numberOfChars; // number of chars in the plaintext
private int[] plainText; // array of plain text ASCII codes
private int[] cipherText; // array of cipher text ASCII codes
private String plainFile; // name of plaintext file
get '/feed', :agent => /FeedBurner (\d\.\d)[\d\/]*?/ do
@posts = Post.reverse_order(:created_at).limit(20)
content_type 'application/atom+xml', :charset => 'utf-8'
builder :feed
end
get '/feed' do
redirect Blog.feedburner_url
end
/***************************************
"The Final Frontier" Web Store (Assignment 1)
Author: John Dyer
Class: CS401
Section: Wednesday
Version: 1.0
Date: 9/24/09
Description: Basic simulation of an "online" store with it's theme being the Final Frontier.
****************************************/
import java.util.*;
@LBRapid
LBRapid / snippet.rb
Created July 19, 2010 13:37
Setup recaptcha keys in an initializer to easily make global changes to settings. Ex: config/initializers/recaptcha.rb
if Rails.env.production?
ENV['RECAPTCHA_PUBLIC_KEY'] = 'your_production_key'
ENV['RECAPTCHA_PRIVATE_KEY'] = 'your_production_key'
else
ENV['RECAPTCHA_PUBLIC_KEY'] = 'your_global_key'
ENV['RECAPTCHA_PRIVATE_KEY'] = 'your_global_key'
end
$('ul .tags').each(function() {
$(this).children('li:gt(4)').hide();
$('li:4').after('<li><a href="#" class="show-hide-tags" data-open="0">[More]</a></li>');
});
$('.show-hide-tags').click(function(e) {
e.preventDefault();
var $this = $(this);
if ($this.attr('data-open') == "0") {
$this.text("[Less]");
}
.tags {
position: absolute;
display: block;
}
.tags li {
bullet-style: none;
display: inline;
}
.show-hide-tags {
// ---------------------------------------------------------------------------------
// TAGGING
// ---------------------------------------------------------------------------------
$('ul.tags').each(function() {
$(this).children('li:gt(4)').hide();
$(this).after('&nbsp<p class="show-hide-tags"><a href="#" data-open="0">[More]</a></p>');
});
$('.show-hide-tags a').click(function(e) {
module HTML
class StathamSanitizer < WhiteListSanitizer
protected
def tokenize(text, options)
super.map do |token|
if token.is_a?(HTML::Tag) && options[:parent].include?(token.name)
token.to_s.gsub(/</, "&lt;")
else
$('ul.tag-list').each(function() {
if($(this).children('li').size() > 5) {
$(this).children('li:gt(4)').hide();
$(this).after('&nbsp<p class="show-hide-tags"><a href="#" data-open="0">&nbsp;[More]</a></p>');
}
});
$('.show-hide-tags a').click(function(e) {
e.preventDefault();
var $this = $(this);
$('.suggested-tags li a').click(function(e) {
if($('.tag-box').attr('data-empty') == 0) {
var tag_text = ', ' + $(this).text();
}else {
var tag_text = $(this).text();
$('.tag-box').attr('data-empty', '0');
}
e.preventDefault();
$('.tag-box input:text').val($('.tag-box input').val() + tag_text);