Skip to content

Instantly share code, notes, and snippets.

View dwaynemac's full-sized avatar

Dwayne Macgowan dwaynemac

View GitHub Profile
@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 / .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 / 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 / .gitignore
Created October 13, 2011 14:39
Shell scripts to manage multiple projects with git
.idea/
# 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
# 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
@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 )
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 / application_controller.rb
Created August 21, 2012 18:06
Typhoeus Arrays decoding in Rails
require 'typhoeus/arrays_decoder'
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :decode_typhoeus_arrays
private
def decode_typhoeus_arrays
2012-12-11T13:33:52+00:00 app[web.1]:
2012-12-11T13:33:52+00:00 app[web.1]:
2012-12-11T13:33:52+00:00 app[web.1]: Started GET "/v0/contacts?per%5Fpage=1000&where%5Blocal%5Fstatus%5Ffor%5Fmatosinhos%5D=student&where%5Bglobal%5Fteacher%5Fusername%5D=pedro%2Emar&page=1&app%5Fkey=844d8c2d20a9cf9e97086df94f01e7bdd3d9afaa716055315706f2e31f40dc097c632af53e74ce3d5a1f23811b4e32e7a1e2b7fa5c128c8b28f1fc6e5a392015" for 50.16.118.56 at 2012-12-11 13:33:52 +0000
2012-12-11T13:33:52+00:00 app[web.1]: Processing by V0::ContactsController#index as */*
2012-12-11T13:33:52+00:00 app[web.1]: Parameters: {"per_page"=>"1000", "where"=>{"local_status_for_matosinhos"=>"student", "global_teacher_username"=>"pedro.mar"}, "page"=>"1", "app_key"=>"844d8c2d20a9cf9e97086df94f01e7bdd3d9afaa716055315706f2e31f40dc097c632af53e74ce3d5a1f23811b4e32e7a1e2b7fa5c128c8b28f1fc6e5a392015"}
2012-12-11T13:33:52+00:00 heroku[router]: at=info method=GET path=/v0/contacts?per%5Fpage=1000&where%5Blocal%5Fstatus%5Ffor%5Fmatosinhos%5D=student&where%5Bg