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 'rubygems' | |
require 'redis' | |
r = Redis.new | |
r.config("SET","maxmemory","2000000") | |
r.config("SET","maxmemory-policy","allkeys-lru") | |
r.config("SET","maxmemory-samples",1000) | |
r.config("RESETSTAT") | |
r.flushall |
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
# register services | |
Application.register :session do | |
SessionStore.new(store: Application.lookup(:database_store)) | |
end | |
Application.register :database_store do | |
# code to initialize database storage for session | |
end | |
# inject session service into every action |
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
git clone git@github.com:lotus/lotus.git | |
git clone git@github.com:lotus/model.git | |
git clone git@github.com:lotus/controller.git | |
git clone git@github.com:lotus/view.git | |
git clone git@github.com:lotus/router.git | |
git clone git@github.com:lotus/helpers.git | |
git clone git@github.com:lotus/utils.git | |
sdoc -o doc/lotus -T direct --exclude="CHANGELOG.md" --exclude="LICENSE.txt" --exclude="LICENSE.md" --exclude="CONTRIBUTING.md" --exclude="test" --exclude="Gemfile*" --exclude=".*gemspec" --exclude="Rakefile" --no-dry-run -t lotus -a lotus | |
sdoc -o doc/model -T direct --exclude="CHANGELOG.md" --exclude="LICENSE.txt" --exclude="LICENSE.md" --exclude="CONTRIBUTING.md" --exclude="test" --exclude="Gemfile*" --exclude=".*gemspec" --exclude="Rakefile" model |
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
diff --git a/lib/lotus/loader.rb b/lib/lotus/loader.rb | |
index e038d7f..9221840 100644 | |
--- a/lib/lotus/loader.rb | |
+++ b/lib/lotus/loader.rb | |
@@ -23,7 +23,6 @@ module Lotus | |
load_configuration! | |
load_frameworks! | |
load_application! | |
- finalize! | |
end |
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
# Visit: | |
# /main/set_flash | |
# /main/show_no_flash (as many times as you like) | |
# /main/show_flash ... and it shows the flash message | |
# (Rails 4.1.8, Ruby 2.1.1) | |
# app/controllers/main_controller.rb | |
class MainController < ApplicationController | |
def show_flash | |
render inline: flash[:notice] || "Flash is blank!" |
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
module Lotus | |
module Repository | |
# Timestamps handling using an entity's @created_at and @updated_at. | |
# | |
# @since 0.2.4 | |
module Timestamps | |
# Override existing public API into hosting class to support @created_at | |
# and @updated_at using Ruby implementations (database agnostic). | |
# | |
# @since 0.2.4 |
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 'lotus/model' | |
require 'json' | |
module Lotus::Model::Mapping::Coercions | |
def self.JSON(arg) | |
return nil if arg.nil? | |
case arg | |
when String | |
JSON.parse(arg) | |
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
class AgencyVisitPolicy | |
def initialize(user) | |
@user = user | |
end | |
def to_proc | |
Proc.new { |visit| visit.agency_id.in?([@user.agency_id, nil]) } | |
end | |
end |
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
# Basic text search with relevancy for MongoDB. | |
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/ | |
# Copythingie 2010 - Ward Bekker - ward@tty.nl | |
#create (or empty) a docs collection | |
doc_col = MongoMapper.connection.db('example_db').collection('docs') | |
doc_col.remove({}) | |
#add some sample data | |
doc_col.insert({ "txt" => "it is what it is"}) |
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
# make an alternative for send_later that accepts a run_at time | |
# | |
module Delayed | |
module MessageSending | |
def send_later_at(at, method, *args) | |
Delayed::Job.enqueue( | |
Delayed::PerformableMethod.new(self, method.to_sym, args), | |
0, #priority | |
at #run_at | |
) |
OlderNewer