Skip to content

Instantly share code, notes, and snippets.

View janxious's full-sized avatar
🌰
.

Joel "The Gregarious" Meador janxious

🌰
.
View GitHub Profile
Any of these should be runnable at the command line by `ruby <filename>`.
Any of these should be runnable at the command line by `ruby <filename>`
@janxious
janxious / ampersand-sample.html
Created March 22, 2011 15:57
All of these things should render the same. Check the ‘h1’s.
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Ampersand Test</title>
</head>
<body>
<h1>Stuff &#x26; Things</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.</p>
<h1>Stuff & Things</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.</p>
@janxious
janxious / DocRaptorPagingSample.html
Created February 3, 2011 02:39
A very basic layout for controlling page sizes
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Document</title>
<style type="text/css">
@page { size: A4; }
@page cover { size: A6 portrait; background-color: rgb(243,241,224); }
#cover { page: cover; }
</style>
</head>
@janxious
janxious / docraptor_form_example.js
Created December 31, 2010 18:37
Hitting DocRaptor using jQuery, v2
// this function is based on code found:
// http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/
// to easily make a form and POST it
var download = function(url, data, method){
//url and data options required
if( url && data ){
jQuery('<form style="display: none" id="dr_submission" action="' + url
+ '" method="' + (method||'post') + '">'
+ '</form>').appendTo('body');
//credentials
class Array
alias :orig_uniq__ :uniq
def uniq(attr = nil)
return orig_uniq__ if attr.nil?
[].tap do |c|
found = []
self.each_with_index do |el, i|
val = el.send(attr)
unless found.include? val
found << val
This is a simple sinatra feedburner proxy. This technique can be used for getting around firewalls and things of that nature.
To use it, you can just `ruby feedburner_proxy.rb` at the cli and then navigate to `http://localhost:4567/FEED_URL`.
e.g. `http://localhost:4567/expectedbehavior` or `http://localhost:4567/jqr`, which will then pull down
'http://feeds2.feedburner.com/expectedbehavior' and 'http://feeds2.feedburner.com/jqr', respectively.
You can check it out at: http://high-spring-46.heroku.com
# Code review
#
# This seems really verbose...seems that there should be a simpler way to conditionally set
# the value of a variable. I would like to write something like:
# body = post.get_formatted_body || ""
#
# That fails when the post is nil. This helper has to deal with a nil post object being passed in
# so I added the .nil? check. This is a contrived version of the situation I have, so don't
# nitpick the details.
#
# -*- coding: utf-8 -*-
module Color
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33, :magenta => 35 }
end
class Test::Unit::Slow
alias :old_long_display :long_display
def long_display
time_index = /\d+\.\d+s$/ =~ old_long_display
time = old_long_display[time_index..-1] if index
@janxious
janxious / activesupport.rb
Created January 31, 2010 22:07 — forked from expectedbehavior/activesupport.rb
Test::Unit Cucumber-style Tagging
module ActiveSupport
module Testing
module Declarative
alias :tu_test_original :test
# test "verify something", [:slow, :wip] do
# ...
# end
def test(name, tags = nil, &block)