This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
pdt_locales | |
All of the included locale classes shipped with pdt. | |
""" | |
import datetime | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# speed up pluck | |
class ActiveRecord::Relation | |
class RailsDateTimeDecoder < PG::SimpleDecoder | |
def decode(string, tuple=nil, field=nil) | |
if Rails.version >= "4.2.0" | |
@caster ||= ActiveRecord::Type::DateTime.new | |
@caster.type_cast_from_database(string) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#define _CheckTypes(a,b) _Static_assert(_Generic(a, typeof (b):1, default: 0), "Mismatched types") | |
#define Min(a,b) \ | |
({ \ | |
const typeof (a) _a = (a); \ | |
const typeof (b) _b = (b); \ | |
_CheckTypes(_a,_b); \ | |
(_a < _b ? _a : _b); \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://gist.github.com/1182136 | |
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer | |
protected | |
def html_container(html) | |
tag :div, tag(:ul, html), container_attributes | |
end | |
def page_number(page) | |
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) |