Samnang Chhun samnang

View .gitignore_global
1 2 3 4 5 6 7 8 9 10
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
 
# Packages #
View notifications_worker.rb
1 2 3 4 5 6 7 8 9 10
class NotificationsWorker
include Sidekiq::Worker
sidekiq_options queue: :notification, retry: false
 
def perform(actor_id, user_ids, action, target_type, target_id)
actor = User.find(actor_id)
target = target_type.constantize.find(target_id)
 
notifications = []
ActiveRecord::Base.transaction do
View api_controller.rb
1 2 3 4 5 6 7 8 9 10
# A Basic API Controller for Rails
# Handles authentication via Headers, params, and HTTP Auth
# Automatically makes all requests JSON format
#
# Written for production code
# Made public for: http://broadcastingadam.com/2012/03/state_of_rails_apis
#
# Enjoy!
 
class ApiController < ApplicationController
View reviews_index_query_spec.rb
1 2 3 4 5 6 7 8 9 10
require 'spec_helper'
 
describe ReviewsIndexQuery do
 
let(:user) { create(:user) }
let(:facility) { user.facility }
 
let(:p1) { create(:patient,
facility: facility,
mrn: '111',
View cases_datable.rb
1 2 3 4 5 6 7 8 9 10
def fetch_cases
cases = (admin? || csm?) ? Case : current_user.cases
cases = cases.order("#{sort_column} #{sort_direction}")
cases = cases.recent.pending_first.includes(:entries, :case_type, :user, :client)
cases = cases.page(page).per(per_page)
if search_term.present?
cases = cases.search_for(search_term)
end
 
cases
View reports_controller.rb
1 2 3 4 5 6 7 8 9 10
class ReportsController < ApplicationController
 
before_filter :authenticate_csm!
 
def pending
#send_csv_data(PendingCasesReport.new.csv, 'pending_cases.csv')
 
setup_streaming_headers
self.response_body = streamer
end
View gist:6895674
1 2 3 4 5 6 7 8 9 10
require 'spec_helper'
require File.expand_path('../../../db/migrate/20130910173340_decrypt_case_identifiers', __FILE__)
 
describe 'Case identifiers decryption migration' do
subject(:migration) { DecryptCaseIdentifiers.new }
 
describe ".up" do
it "decrypts identifier of each case" do
cases = create_list(:case, 2)
cases[0].update_column(:identifier, encrypt('12345'))
View 1_decorator.rb
1 2 3 4 5 6 7 8 9 10
class FacebookCommentNotifer
def initialize(comment)
@comment = comment
end
 
def save
@comment.save && post_to_wall
end
 
private
View gist:6227869

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

View app.rb
1 2 3 4 5 6 7 8 9 10
class App
def initialize(primary_force, secondary_force, delay, mass)
@primary_force = primary_force
@secondary_force = secondary_force
@delay = delay
@mass = mass
end
 
def distance_traveled(time)
acc = @primary_force / @mass
Something went wrong with that request. Please try again.