Skip to content

Instantly share code, notes, and snippets.

hello test gist
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@paramaw
paramaw / error-vk-ruby-1.0.1
Created September 19, 2014 06:47
error vk ruby 1.0.1
paramaw@ParamaPro:keychain-proxy (master) rails c
A syntax error has occurred:
unknown type of % string: /Users/paramaw/.rvm/gems/rbx-2.2.10/gems/vk-ruby-1.0.1/lib/vk-ruby/params.rb:41:7
Code:
%i[host verb timeout open_timeout ssl proxy middlewares stack].inject(options.dup) do |result, name|
^
Backtrace:
@paramaw
paramaw / mongodb_collection_sizes.js
Last active March 5, 2019 14:52 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of storageSize. Helpful for finding largest collections. First number is "size," second is "storageSize."
# TO FIND OUT WHICH COLLECTIONS ARE THE LARGEST (MONGODB CONSOLE)
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { try{ stats.push(db[n].stats());}catch(e){} });
stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize']/1024/1024/1024 + " GB)"); }
# AND TO DELETE A COLLEECTION IN Henhouse Rails console:
collections = %W(
@paramaw
paramaw / compact.js
Last active February 24, 2018 04:44 — forked from BlakeGardner/compact.js
Compact all collections inside of a MongoDB database
// This script loops though the list of collection names in a MongoDB and runs the compact operation on them
// Simply paste this into the Mongo shell
use testDbName;
db.getCollectionNames().forEach(function (collectionName) {
print('Compacting: ' + collectionName);
db.runCommand({ compact: collectionName, force: true });
});
@paramaw
paramaw / installing_cassandra.md
Created April 9, 2018 19:57 — forked from hkhamm/installing_cassandra.md
Installing Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"