Skip to content

Instantly share code, notes, and snippets.

View courtenay's full-sized avatar

C o u r t e n a y courtenay

  • ENTP
  • Mars
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<body>
<script type="text/javascript">
var foo = 'asdfkajhsdf as</script><script>alert("xss1")</script>';
var bar = "asdfasdf </script><script>alert('xss2')</script>";
</script>
</body>
</html>
@courtenay
courtenay / gist:7343845
Last active September 18, 2018 03:35
before(:all) hacks for minitest
module Fixtures
#
# Set up fixtures that will be defined once during startup
# and (perhaps) rolled back at the beginning of each test run
#
def fixtures &block
if block_given?
instance_eval &block
@fixtures = {}
(instance_variables - [:@fixtures]).each do |fresh|
# html
<div class="user">
<img src="/avatar.gif" />
<h4>Jimbo Jones</h4>
</div>
# css
div.user {
@courtenay
courtenay / STDOUT
Last active December 16, 2015 15:19
add the "<a name" and span icon there as well, so you can style it with a cute little hoverable link
# output
> gh = Redcarpet::Render::GithubStyleTitles.new
> puts Redcarpet::Markdown.new(gh).render "test\n\n# test 1\n\n# test 2\n\n# test 1\n\n# test 1"
=>
<a name="test-1" class="anchor" href="#test-1"><span class="anchor-icon"></span></a><h1 id="test-1">test 1</h1>
<a name="test-2" class="anchor" href="#test-2"><span class="anchor-icon"></span></a><h1 id="test-2">test 2</h1>
@courtenay
courtenay / gist:4498771
Last active December 10, 2015 21:59
MONKEY PATCH: no "xml type=yaml" in your .to_xml dump of activerecord objects
# RAILS 2.3.15
#
# Since <tag type="yaml"> was removed from rails' xml parsing,
# but not from its to_xml method, rails can't talk to an API
# generated by rails, if you have serialized attributes.
# This can be put in config/initializers and you should probably
# upgrade to rails 3 already. Ugh.
# Three parts:
def hipchat_hook(data, payload, log)
notify_hipchat data,
"[Tender] \"#{payload['discussion']['title']}\" has been #{payload['number'] > 1 ? 'updated' : 'opened'} by #{payload['author_name']}",
payload['discussion']['html_href']
end
@courtenay
courtenay / autosuggest.html
Created April 18, 2012 22:29
Tender: Sample jsonp autosuggest implementation.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test JSONP search api</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
</head>
@courtenay
courtenay / Gemfile
Created November 23, 2011 06:00 — forked from netpro2k/Gemfile
source :gemcutter
gem 'CFPropertyList'
gem 'eventmachine'
gem 'uuidtools'
gem 'libxml-ruby'
# load plugins
require 'yaml'
# sample stats recording code
base = "w:#{site_id}:#{word}"
# hits per year
REDIS.incr "#{base}:#{created_at.year}"
# hits per month
REDIS.incr "#{base}:#{created_at.month}-#{created_at.year}"
@courtenay
courtenay / gist:1118441
Created August 1, 2011 16:14
simple rack app
require 'stringio'
class TestLeak
def self.call(env)
str = env["rack.input"].read
puts env.inspect
puts str
env["rack.input"] = nil