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
# Experiment, only tested under Rails 3.2.16, not sure how useful it really is... | |
# "Works" only with where conditions using a Hash | |
# | |
# Example: | |
# User.where :created_at::date => "2014-01-01" # :created_at is a timestamp | |
# | |
module PgCast | |
# All of these are not really viable | |
TYPES = %w[any char abstime aclitem anyarray anyelement anyenum anynonarray bigint bit bit varying boolean box bytea character character varying cid cidr circle cstring date double precision gtsvector inet int2vector integer internal interval language_handler line lseg macaddr money name numeric oid oidvector opaque path point polygon real record refcursor regclass regconfig regdictionary regoper regoperator regproc regprocedure regtype reltime smallint smgr text tid time with time zone time without time zone timestamp with time zone timestamp without time zone tinterval trigger tsquery tsvector txid_snapshot unknown uuid void xid xml] |
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
use Mojo::Base -strict; | |
use Mojo::Collection; | |
use Mojo::Util 'monkey_patch'; | |
use Data::Dump 'dd'; | |
monkey_patch 'Mojo::Util', | |
c => sub { Mojo::Collection->new(Mojo::Util::array(@_)) }, | |
array => sub { | |
my @data = ( @_ == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_ ); |
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
# /a/b.txt | |
# /a/c.txt | |
# /a/d/e/ | |
# /a/d/f.txt | |
:a => [ | |
"b.txt", | |
"c.txt", | |
:d => [ "e/", "f.txt" ] | |
] |
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
# | |
# Auto-generated by jaxb2ruby v0.0.1 on 2014-07-05 13:57:07 -0400 | |
# https://github.com/sshaw/jaxb2ruby | |
# | |
require "happymapper" | |
module Com module Example module Person | |
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
require "uri" | |
# | |
# Generate Amazon Affiliate URLs for products and searches | |
# | |
# Amazon::AffiliateURL.config do |cfg| | |
# cfg.id = "your-id" # required | |
# cfg.domain = :us # optional, defaults to :us, can be a domain name | |
# cfg.category = "grocery" # optional, default category for search(), | |
# cfg.secure = true # optional, use https scheme or not, defaults to false |
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
require "date" | |
# Small DSL for idiomatic date parsing and formatting in Ruby. | |
# https://gist.github.com/sshaw/53c27b148e903a07e494 | |
# | |
# Usage: | |
# | |
# include YYMMDD | |
# date = Date.today | |
# |
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
brew install berkeley-db4 | |
gem install sbdb -- --with-db-lib=/usr/local/opt/berkeley-db4/lib --with-db-include=/usr/local/opt/berkeley-db4/include/ |
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
require "gdbm" | |
require "sucker_punch" | |
class IdBasedJob | |
include SuckerPunch::Job | |
def perform(db, ids) | |
ids.each do |id| | |
SuckerPunch.logger.info(sprintf "Running %s [%d]\n", id, Thread.current.object_id) | |
if do_some_thang |
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
Gem::Specification.new do |s| | |
s.name = "bh-flash" | |
s.version = "0.0.2" | |
s.date = "2015-08-02" | |
s.summary = "Render flash messages using Bootstrap Helpers" | |
s.description =<<-DESC | |
Render flash messages using Bootstrap Helpers: http://fullscreen.github.io/bh/ | |
Inspired by: https://github.com/planetargon/flash-message-conductor | |
DESC | |
s.authors = ["Skye Shaw"] |
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
# Usage: | |
# referer? :controller => 'beezies', :action => 'holla', :type => 'popozuda' | |
# referer? %r|/\d+/edit| | |
def referer?(options) | |
referer = request.headers["Referer"] | |
return (options.blank? ? true : false) if referer.blank? | |
if options.is_a?(Regexp) | |
referer =~ options |
OlderNewer