Skip to content

Instantly share code, notes, and snippets.

View victorhazbunanuff's full-sized avatar

victor hazbun anuff victorhazbunanuff

  • koombea
  • barranquilla
View GitHub Profile
...
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
config.authentication_keys = [ :login ]
# before filter for api controller
def verify_authenticity_token
@current_user = User.find_by_authentication_token(params[:auth_token])
render status: 401, json: { message: '...' } and return unless @current_user
end
module AccountSupport::CacheManager
extend ActiveSupport::Concern
included do
# Returns the cached users of an account
def cached_users
Rails.cache.fetch("#{id}_account.users") { member_users.all }
end
# Returns the cached teammates of an account
@victorhazbunanuff
victorhazbunanuff / example.js
Created August 29, 2013 16:42
managing memory
function createPerson(name){
var localPerson = new Object();
localPerson.name = name;
return localPerson;
}
var globalPerson = createPerson("Nicholas");
// do something with globalPerson
@victorhazbunanuff
victorhazbunanuff / solution
Created August 20, 2013 15:51
command not found: mailcatcher
1. Open ~/.bash_profile
2. copy and paste LC_CTYPE="utf-8"
3. Execute mailcatcher
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@victorhazbunanuff
victorhazbunanuff / global.js
Last active December 20, 2015 19:49
Copy and reflect values from an element to another
function ReflectValueOnKeyUp(from, to, options) {
var options = options || {};
var escape_string = options.escape_string || false;
$(from).keyup(function(){
var that = $(this);
if (options.escape_string == true) {
$(to).val(escapeString(that.val()));
} else {
$(to).val(that.val());
}
class AccountDeletionJob
@queue = :account_deletion
# Warning .perform will destroy an account from the database.
def self.perform(account_id)
account = Account.find(account_id)
if account
Account.transaction do
begin
account.destroy!
AccountAlertMailer.deletion_notification(account).deliver
require_relative '../../app/services/recurly_account_checker'
require 'recurly'
describe RecurlyAccountChecker do
let(:user) { stub }
let(:customer) { stub }
let(:customer_id) { -1 }
before do
user.stub(:customer_id) { customer_id }
Recurly::Account.stub(:find) { customer }
end
def delayed_deletion
begin
Account.transaction do
update_column(:deleted_at, Date.current)
destroy_subscription
end
rescue Exception; end;
AccountAlertMailer.deletion_notification(admin).deliver
end