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
| var current_directory = 'downloads'; | |
| $.get('adminajax.php', {'action':'getDirectory', 'directory':current_directory}, function(data){ | |
| $('#files .files').html(data); | |
| deleteUser(); | |
| }); | |
| $.get('adminajax.php', {'action':'getUsers'}, function(data){ | |
| $('#users .users').html(data); | |
| deleteUser(); | |
| }); |
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
| $.delete('adminajax.php', {'action':'deleteUser', 'user':'[username]'}, function(data){ | |
| alert('The user has just been deleted!'); | |
| }); |
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
| group :production, :staging, :development do | |
| # View related | |
| gem "simple_form", "~> 2.1.0" | |
| gem "haml-rails", "~> 0.4" | |
| gem "jquery-rails", "~> 2.2.1" | |
| gem "will_paginate", "~> 3.0" | |
| end | |
| group :development, :test do | |
| gem "pry-rails", :require => false |
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
| # Bad | |
| describe '...' do | |
| before do | |
| @user = create(:user) | |
| @post = create(:post) | |
| end | |
| it '......' do | |
| expect(@user).to be_valid | |
| 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
| class DeferredGarbageCollection | |
| DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f | |
| @@last_gc_run = Time.now | |
| def self.start | |
| GC.disable if DEFERRED_GC_THRESHOLD > 0 | |
| 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
| RSpec.configure do |config| | |
| config.before do | |
| DatabaseCleaner.strategy = :transaction | |
| end | |
| config.before(:each, :feature => true) do | |
| DatabaseCleaner.strategy = :deletion # or :truncation | |
| end | |
| 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
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = :transaction | |
| 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
| irb(main):032:0> user.confirmed_at | |
| => Wed, 05 Jun 2013 00:00:52 HKT +08:00 | |
| irb(main):046:0> user.confirmed_at.utc | |
| => 2013-06-04 16:00:52 UTC | |
| irb(main):033:0> User.where('confirmed_at > ? and confirmed_at < ?', Date.new(2013,6,4), Date.new(2013,6,5)).include?(user) | |
| => true | |
| irb(main):034:0> User.where('confirmed_at > ? and confirmed_at < ?', Date.new(2013,6,5), Date.new(2013,6,6)).include?(user) | |
| => false | |
| irb(main):042:0> Date.new(2013,6,4).to_time | |
| => 2013-06-04 00:00:00 +0000 |
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
| def self.send_confirmation_reminder | |
| self.where(confirmed_at: nil).each do |user| | |
| if (1.day..2.days).include?(Time.current - user.confirmation_sent_at) || (3.days..4.days).include?(Time.current - user.confirmation_sent_at) | |
| UserMailer.confirmation_reminder(user).deliver | |
| end | |
| end | |
| end | |
| def self.send_application_reminder | |
| self.all.map(&:loans).flatten.uniq.each do |loan| |
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
| # mongoid 2.0.0.beta.20 | |
| >Account.first.users.where(:name=>/a/).class => Mongoid::Criteria | |
| >Account.first.users.class => Mongoid::Criteria | |
| # mongoid 2.0.0.rc.7 | |
| >Account.first.users.where(:name=>/a/).class => Mongoid::Criteria | |
| >Account.first.users.class => Array |