Skip to content

Instantly share code, notes, and snippets.

View sunaku's full-sized avatar

Suraj N. Kurapati sunaku

View GitHub Profile
@sunaku
sunaku / STDOUT
Last active May 25, 2018 20:48 — forked from courtenay/STDOUT
Further refinement of @jcemer's modifications at <https://gist.github.com/courtenay/5454972#comment-912976> Strictly speaking, we're generating [URI fragments](http://en.wikipedia.org/wiki/Fragment_identifier), not permalinks.
$ irb
## ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
>> require './github_style_titles.rb'
true
>> gh = Redcarpet::Render::GithubStyleTitles.new
#<Redcarpet::Render::GithubStyleTitles:0x00000001cc3a48>
>> 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" href="#test-1" class="anchor"><span class="anchor-icon"></span></a><h1 id="test-1">test 1</h1>
def self.valid_time?(time)
(0 .. 2359).include? Integer(time)
rescue ArgumentError # invalid integer
false
end
@sunaku
sunaku / gist:574080
Created September 10, 2010 17:58 — forked from mikz/gist:574015
def quoted_date(value)
base = value.respond_to?(:getutc) ? value.getutc.to_s(:db) : super
usec = sprintf(".%06d", value.usec) if value.respond_to?(:usec)
zone = " #{value.formatted_offset}" if value.respond_to?(:formatted_offset)
"#{base}#{usec}#{zone}"
end
require 'ember'
module ActionView
module TemplateHandlers
##
# @example Pass template processing options to Ember
#
# ActionView::TemplateHandlers::Ember.options = {
# :unindent => true,
# :shorthand => true,