Skip to content

Instantly share code, notes, and snippets.

View dwaynemac's full-sized avatar

Dwayne Macgowan dwaynemac

View GitHub Profile
class CommunicationSearch < Search
attr_accessor :full_name
def results(base = nil)
if self.full_name.present?
contacts = PadmaContact.paginate :where => { :full_name => self.full_name }, :per_page => 999999
base = base.where(:contact_id => contacts.map(&:id))
end
...
base
@dwaynemac
dwaynemac / persisting_mongoid_criteria.rb
Created January 3, 2012 20:07 — forked from olivoil/persisting_mongoid_criteria.rb
Example model to persist Mongoid::Criteria as Searches
class Search
include Mongoid::Document
field :query, :type => Hash
field :collection
embedded_in :user
def to_criteria
Mongoid::Criteria.new( collection.titleize.constantize ).fuse( query )
# In CONTACTS WS
# V0::ContactsController
# POST create
# if it recieves image
# should store it on amazon and link it to contact
# PUT update
# if it recieves image
# should store it on amazon and link it to contact
# should delete previous image
# DELETE destroy
# pero agregué este spec en contacts y pasa
# así que debe ser algo de como CRm esta creando el contact,no?
it "should allow access to contacts" do
l = List.make
a = l.account
c = Contact.make(:lists => [l])
l.reload
l.contacts.should == [c]
a.lists.first.contacts.should == [c]
end
@dwaynemac
dwaynemac / .gitignore
Created October 13, 2011 14:39
Shell scripts to manage multiple projects with git
.idea/
@dwaynemac
dwaynemac / heroku.sh
Created September 21, 2011 14:26
Creates heroku application with most used addons
heroku create $1
heroku addons:add pgbackups:auto-month
heroku addons:add custom_domains:basic
heroku addons:add zerigo_dns:basic
heroku addons:add newrelic:standard
heroku addons:upgrade logging:expanded
@dwaynemac
dwaynemac / .bachrc.sh
Created September 16, 2011 15:16
Para ver el current branch de git en el shell
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
@dwaynemac
dwaynemac / statistica_README.rdoc
Created September 8, 2011 18:32
statistica README updated on 8sep2011

Seguridad

Todos los requests deben ser realizandos enviando API_KEY via GET

Listar escuelas

Request

GET /schools
@dwaynemac
dwaynemac / git_cheatsheet.rdoc
Created August 9, 2011 22:34
RDoc explicando el workflow

Git CheatSheet

  • Corregir mi último commit:

    git commit –amend

  • Cambiar de branch:

    git checkout branch_name

@dwaynemac
dwaynemac / .bashrc
Created April 21, 2011 17:16
Bootstrap Ubuntu 10.10 Live-USB for Ruby development
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
if [[ -n "$PS1" ]]; then
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace