Skip to content

Instantly share code, notes, and snippets.

View ejlangev's full-sized avatar

Ethan Langevin ejlangev

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ejlangev on github.
  • I am ejlangev (https://keybase.io/ejlangev) on keybase.
  • I have a public key whose fingerprint is 81F7 F97E A17A A08F 700B E0D3 12B5 3827 1EB8 6F18

To claim this, I am signing this object:

class Postman
include Interactor
def perform(context)
create_message_log
CreateMessageSummary.perform(context)
EnqueueMessageJob.perform(context)
class Postman
include Interactor
def perform
if should_send_push_notification?
Postman::SendPushNotification.perform(context)
else
Postman::SendTextMessage.perform(context)
end
feature "Short Messaging" do
let(:member) { create(:member) }
let(:admin) { create(:admin) }
let(:message) {
GrouperShortMessager.custom_message(message, admin, "Hello, World!")
}
around do |example|
previous_value = Resque.inline
@ejlangev
ejlangev / dare_update.rb
Created April 25, 2014 20:13
For updating dare category
Dare.where(category: 'Next Level').update_all(category: "Next Level Dares")
Dare.where(category: 'Warm Up').update_all(category: 'Get Warmed Up')
@ejlangev
ejlangev / gist:11301858
Created April 25, 2014 20:18
Make sure all bounce venues are in the same city as their parent venue
Venue.where('bounce_venue_id IS NOT NULL').includes(:bounce_venue).select { |v| v.city_id != v.bounce_venue.city_id }.map(&:id)
@ejlangev
ejlangev / gist:11380168
Created April 28, 2014 18:30
Example of page specific js
$ ->
$("#scared, #down-arrow, #example-button").click ->
$("html, body").animate
scrollTop: $("#dares-photos").offset().top
, 1000
return false
class CreditCardController < ApplicationController
def create
creator = CreditCardCreator.call(params)
# creator.respond_to?(:errors) => true
# creator.errors => [] (by default)
# when something goes wrong: creator.errors => ['Terrible Error']
respond_with(creator)
end
end
@ejlangev
ejlangev / gist:f67fadb4b5497d897452
Created July 29, 2014 19:00
Foreign Key Validator
class ForeignKeyValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value && value.to_s =~ /^\d+$/ && value.to_i > 0
record.errors[attribute] << 'is not a valid foreign key'
end
end
end
{
"size": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"exists": {
"field": "address.full"