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 Admin::CacheHelper | |
def cache_with_permissions(name=[], options = nil, &cache_block) | |
permission_version = options && options[:permission_version] || :v0 | |
permission_required = get_cache_key_for(name, permission_version, &cache_block) | |
name = name + permission_required | |
cache(name, options) { cache_block.call } | |
end | |
def get_cache_key_for(fragment_key, version, &cache_block) |
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
var holidays = [ ['04/5/2015', '04/11/2015'], ['4/26/2015', '4/28/2015'], ['4/30/2015', '5/8/2015'] ]; | |
function highlightDays(date) { | |
for (var i = 0; i < holidays.length; i++) { | |
var in_range = (new Date(holidays[i][0]) <= date) && (new Date(holidays[i][1]) >= date); | |
if (in_range) { | |
return [false]; | |
} | |
} | |
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
# app/models/event.rb | |
# Event model has a set (event_users_ids) tracking all the users that has an inscription to it. | |
# The set update is made in the inscription model which models the relation between the event and its participants. | |
# The operation to get the friends participating in one event is done via redis set operations (&) | |
class Event < ActiveRecord::Base | |
include Redis::Objects | |
has_many :inscriptions | |
set :event_users_ids | |
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
# app/models/concerns/counter.rb | |
require 'active_support/concern' | |
module Counter | |
module Updater | |
extend ActiveSupport::Concern | |
included do | |
after_create :update_counters | |
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
class CreateEvent < ActiveRecord::Migration | |
def change | |
create_table :events do |t| | |
t.string :status | |
t.datetime :scheduled_at | |
t.datetime :started_at | |
t.datetime :finished_at | |
t.datetime :canceled_at | |
t.timestamps |
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
server { | |
listen 80; | |
gzip on; | |
gzip_min_length 1000; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_types text/plain application/xml application/json text/css application/javascript image/svg+xml; | |
root /var/www/et-blog/current; |
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
package com.et.models; | |
import com.et.util.EventGalleryParam; | |
import com.et.util.airbrake.AirbrakeLogFactory; | |
import com.et.util.persistence.ORM; | |
import org.apache.log4j.Logger; | |
import java.sql.ResultSet; | |
import java.util.ArrayList; | |
import java.util.Date; |
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
public MultipleArgumentsExample { | |
public void say(String... words) { | |
for(int i = 0; i < words.length; i++) | |
System.out.println(words[i]); | |
} | |
public void say(String cheers, String... words) { | |
System.out.println(cheers); | |
say(words); |
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
private void stubEditCall(Booking booking, int updatedGuestCount, Date updatedBookingAt, | |
Long updatedTableAreaId, boolean success) throws Exception { | |
Method[] methods = MemberMatcher.methods(Booking.class, "editCheckingETAvailability"); | |
expectPrivate(booking, methods[0], updatedGuestCount, updatedBookingAt, | |
updatedTableAreaId).andReturn(success); | |
replay(booking, Booking.class); | |
} |
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
SELECT | |
AVG(count) | |
FROM # here the derivate table comes | |
(SELECT | |
COUNT(*) AS count | |
FROM | |
`bets` | |
WHERE | |
state = 'pending' | |
GROUP BY user_id |
OlderNewer