Skip to content

Instantly share code, notes, and snippets.

@heptat
heptat / gist:10436561
Created April 11, 2014 01:42
rails 4.1 JSON API problem
class ApplicationController < ActionController::Metal
include ActionController::Helpers
include ActionController::Redirecting
# Rendering MUST be before Renderers::All
include AbstractController::Rendering
include ActionController::Renderers::All
# this is now in ActionView::Layouts:
# include AbstractController::Layouts
include ActionView::Layouts
kd = Word.find(1)
kd.translated_words.each do |tw|
puts tw.text
puts tw.language
end
$found = false;
$sessionID = uniqid();
$i = 0;
$MAX_ITERATIONS = 500;
while ($found && $i < $MAX_ITERATIONS) {
// do some stuff
}
@heptat
heptat / fizzbuzz.rb
Created October 17, 2012 04:00
fizzbuzz
# in this version of FizzBuzz the words have to be separated by a comma
def fizzbuzz(number)
output = nil
if number % 3 == 0
output = "Fizz"
end
@heptat
heptat / mocktest.php
Created May 17, 2012 06:33
mock test
<?php
namespace app\tests\mocks\models;
use lithium\data\entity\Document;
use lithium\data\collection\DocumentSet;
class MockTests extends \app\models\Tests {
public static function &connection() {
@heptat
heptat / update.php
Created March 30, 2012 01:31
update
<?php
static::applyFilter('save', function($self, $params, $chain) {
// TODO if they are applying for concession, write this to the mysql_
// "registrations" table
$data = $params['entity']->data();
if ($data['registration_fee_type'] == 'concession') {
$registration = Registrations::first(array('conditions' => array('id' => $data['registration_id'])));
$registration->concession_applied_for = 1;
$registration->save(null, array('validate' => false));
}
@heptat
heptat / li3_rel.php
Created February 27, 2012 12:16
li3 relationship
<?php
// registrations model, foreign key is session_id and *not* venue_session_id:
class Registrations extends \lithium\data\Model {
public $belongsTo = array(
'VenueSessions' => array('key' => array('session_id' => 'id')),
// also tried this, which doesn't work:
// 'VenueSessions' => array('class' => 'VenueSessions', 'key' => 'session_id'),
);
...
[root@localhost] local/www/oars # git merge x-correct-http-methods2 2011-08-18 23:20:26 root pts/4
Auto-merging tests/capybara/step_definitions/capybara_steps.rb
Merge made by recursive.
controllers/ConnectionController.php | 7 ++-
controllers/ItemsController.php | 1 +
.../client_admin/candidate_retrieve.feature | 2 +-
tests/capybara/step_definitions/capybara_steps.rb | 41 +++++++++++++--
.../step_definitions/client_admin_steps.rb | 54 +++++++++++--------
tests/capybara/support/env.rb | 9 ++-
views/candidates/index.html.php | 2 +-
@heptat
heptat / gist:1141281
Created August 12, 2011 02:01
failing tests 2011.08.11 (client-admin, delivery, admin, registration)
Client-admin:
Failing Scenarios:
cucumber -p client-admin-all client_admin/candidate_create.feature:84 # Scenario: Add a new candidate using an existing candidate username
cucumber -p client-admin-all client_admin/client_create.feature:34 # Scenario: Add a new client and be directed to the login page
172 scenarios (2 failed, 170 passed)
2221 steps (2 failed, 4 skipped, 2215 passed)
Delivery:
@heptat
heptat / gist:1138762
Created August 11, 2011 02:04
all failing tests 2011.08.11
cucumber -p client-admin-all client_admin/
Failing Scenarios:
cucumber -p client-admin-all client_admin/candidate_create.feature:23 # Scenario: Navigating to create candidates page for a client that doesn't exist
cucumber -p client-admin-all client_admin/candidate_create.feature:84 # Scenario: Add a new candidate using an existing candidate username
cucumber -p client-admin-all client_admin/client_create.feature:34 # Scenario: Add a new client and be directed to the login page
172 scenarios (3 failed, 169 passed)
2221 steps (3 failed, 8 skipped, 2210 passed)