Skip to content

Instantly share code, notes, and snippets.

Avatar

C o u r t e n a y courtenay

  • ENTP
  • Mars
View GitHub Profile
View gist:11376226
<!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 Sep 18, 2018
before(:all) hacks for minitest
View gist:7343845
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|
View gist:6968583
# html
<div class="user">
<img src="/avatar.gif" />
<h4>Jimbo Jones</h4>
</div>
# css
div.user {
@courtenay
courtenay / STDOUT
Last active Dec 16, 2015
add the "<a name" and span icon there as well, so you can style it with a cute little hoverable link
View STDOUT
# 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 Dec 10, 2015
MONKEY PATCH: no "xml type=yaml" in your .to_xml dump of activerecord objects
View gist:4498771
# 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:
View hipchat_command.rb
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 Apr 18, 2012
Tender: Sample jsonp autosuggest implementation.
View autosuggest.html
<!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>
View Gemfile
source :gemcutter
gem 'CFPropertyList'
gem 'eventmachine'
gem 'uuidtools'
gem 'libxml-ruby'
# load plugins
require 'yaml'
View gist:1118530
# 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}"
View gist:1118441
require 'stringio'
class TestLeak
def self.call(env)
str = env["rack.input"].read
puts env.inspect
puts str
env["rack.input"] = nil
You can’t perform that action at this time.