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
Mock::generatePartial('Article','MockArticle', array('testCall')); | |
// then inside the test case class: | |
public function startTest($method) { | |
parent::startTest($method); | |
$this->Article = new MockArticle($this); | |
$this->Article->alias = 'Article'; | |
$reflectionMethod = new ReflectionMethod('Article', '__construct'); | |
$reflectionMethod->invoke($this->Article); |
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
{"comment"=>{"author"=>"test", | |
"content"=>"test"}, | |
"commit"=>"Create Comment", | |
"authenticity_token"=>"wGpdIZVeimdsUCdiu0WeeCDoXiclqK0IcGUjwIvGTfQ=", | |
"utf8"=>"✓", | |
"announce_id"=>"1-dummy-title"} |
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
#show.js.erb | |
$('#comments').html('<%= escape_javascript render(@comments) %>'); | |
$('#paginator').html('<%= escape_javascript(paginate(@comments, :remote => true).to_s) %>'); | |
#announces_controller.rb | |
def show | |
@announce = Announce.find(params[:id]) | |
@comments = Comment.order("created_at desc").where(:announce_id => @announce.id).includes(:attachments).page(params[:page]).per(10) | |
@comment = @announce.comments.build | |
@comment.attachments.build |
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
#publications_controller | |
def show | |
@comments = @publication.comments.includes(:author => :user).order('created_at desc').page(params[:page]).per(10) | |
@comment = @publication.comments.build | |
end | |
#comments_controller | |
def create | |
@publication = Publication.find(params[:publication_id]) |
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 Teacher < User | |
has_many :grades, :through => :teachings, :uniq => true | |
has_many :teachings | |
has_many :subjects, :through => :teachings, :uniq => true | |
def teaching_grades(organization) | |
grades.where('teachings.grade_id' => Grade.where(:organization_id => organization.id)) | |
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
/* | |
* Ajax file upload experiment | |
*/ | |
AjaxUploadHandler = function(o){ | |
this._options = { | |
action: '/upload.php', | |
onProgress: function(fileName, loaded, total){}, | |
onComplete: function(fileName, response){}, | |
onCancel: function(id, fileName){} |
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
######### Show git branch name and info in prompt ############### | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" |
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
# -*- coding: utf-8 -*- | |
""" | |
webapp2 | |
======= | |
Taking Google App Engine's webapp to the next level! | |
:copyright: 2011 by tipfy.org. | |
:license: Apache Sotware License, see LICENSE for details. | |
""" |
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
#!/usr/bin/env python | |
# | |
import os | |
import sys | |
# Hardwire in appengine modules to PYTHONPATH | |
# or use wrapper to do it more elegantly | |
appengine_dirs = ['/Applications/blah/blah/google_appengine'...] | |
sys.path.extend(appengine_dirs) | |
# Add your models to path |
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
#!/bin/bash | |
function actual_path() { | |
if [ [ -z "$1" ] -a [ -d $1 ] ]; then | |
echo $(cd $1 && test `pwd` = `pwd -P`) | |
return 0 | |
else | |
return 1 | |
fi | |
} |
OlderNewer