This file contains hidden or 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
module Modules | |
class OrderPdf | |
include ActionView::Rendering | |
def initialize(order) | |
@order = order | |
@view = ActionView::Base.new(ActionController::Base.view_paths, {}) | |
@view.extend(ApplicationHelper) | |
@view.extend(AbstractController::Rendering) | |
@view.extend(Rails.application.routes.url_helpers) |
This file contains hidden or 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
module Celluloid | |
module Supervision | |
class Container | |
# Manages a fixed-size pool of actors | |
# Delegates work (i.e. methods) and supervises actors | |
# Don't use this class directly. Instead use MyKlass.pool | |
class Pool | |
def initialize(options={}) | |
@idle = [] | |
@busy = [] |
This file contains hidden or 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
# inspired by https://github.com/biilmann/mongo_sessions | |
require 'rack/session/abstract/id' | |
class Session | |
include Mongoid::Document | |
field :sid | |
field :data | |
field :ts, type: Integer | |
index :sid, unique: true #dont forget Session.create_indexes | |
def Session.find_by_sid(sid) | |
Session.first(conditions: {sid: sid}) |
This file contains hidden or 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 'asana' | |
access_token = '12345678' | |
project_id = 12345678 # find this in your URL | |
user_id = 12345678 # found this by right clicking on my avatar in asana and inspecting element - it's in the URL there | |
COMMENT_CHAR = '#' # replace with your editor's comment character(s) | |
client = Asana::Client.new do |c| | |
c.authentication :access_token, access_token | |
end |
This file contains hidden or 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 simple and elegant function to synchronize multiple functions that expect callback as their last parameter. | |
example: | |
sync(func1, [parms], func2, func3, func4, [parms], callback); | |
Public domain!! | |
please leave me a comment if you like it! | |
*/ |
This file contains hidden or 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 'json' | |
require 'active_support/core_ext/numeric/bytes' | |
require 'delegate' | |
require 'forwardable' | |
require 'time' | |
require 'celluloid/io' | |
require 'websocket/driver' | |
require 'webmachine' | |
require 'webmachine/adapters/rack' | |
require 'celluloid/autostart' |
This file contains hidden or 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
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler | |
if defined?(::Bundler) | |
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib") | |
end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
ENV["BUNDLE_IGNORE_CONFIG"] = 'true' | |
install_only = ARGV.to_a.map(&:to_sym) | |
install_only = [:host] if install_only.empty? | |
require 'bundler' | |
Bundler.configure |