Skip to content

Instantly share code, notes, and snippets.

@heptat
heptat / gist:827085
Created February 15, 2011 04:11
sum of even fibonacci numbers under 4000000
#include <stdio.h>
#include <math.h>
int main(void) {
int N = 4000000;
double ratio = 1.61803399;
int n;
int sum = 0;
double tmp = 0.0;
cucumber -p builder builder/cluster_update.feature:139 # Scenario: Verify that units that already belong to a cluster won't show in the list when editing that cluster
cucumber -p builder builder/form_update.feature:92 # Scenario: Verify that clusters that already belong to a form won't show in the list when editing that form
cucumber -p builder builder/form_update.feature:104 # Scenario: View link to delete a cluster from a form
cucumber -p builder builder/form_update.feature:112 # Scenario: Delete a cluster from a form that has one cluster
cucumber -p builder builder/test_publish.feature:60 # Scenario: Visit delete form page for a form that belongs to a published and receive an error message
cucumber -p builder builder/test_publish.feature:92 # Scenario: Visit edit cluster page for a cluster that belongs to a published and receive an error message
cucumber -p builder builder/test_publish.feature:108 # Scenario: Visit delete cluster page for a cluster that belongs to a published and receive an error message
c
# assume the field to search on is "name"
Given /^the ([^\s]+) "([^"]+)" belongs to(?: the) ([^\s]+) "([^"]+)"$/ do |model, value, parent_model, parent_value|
Given "the #{model} with the name \"#{value}\" belongs to the #{parent_model} with the name \"#{parent_value}\""
end
Given /^the ([^\s]+) with the ([^\s]+) "([^"]+)" belongs to(?: the) ([^\s]+) with the ([^\s]+) "([^"]+)"$/ do |model, field, value, parent_model, parent_field, parent_value|
# get the id for the first thing
# get the id for the second thing
model_id = get_id(model, field, value)
parent_id = get_id(parent_model, parent_field, parent_value)
@heptat
heptat / validator.php
Created May 16, 2011 05:42
validator
Validator::add('uniqueFieldForClient', function($value, $format = null, $options = array()) {
$class = $options['class'];
$field = $options['field'];
$conditions = array($field => $value);
if (isset($options['values']['id'])) {
$conditions[] = 'id != ' . $options['values']['id'];
}
// TODO should I throw an exception if client_id is missing? otherwise it's
@heptat
heptat / test.php
Created May 21, 2011 13:31
failing test of test
<?php
namespace app\tests\cases\models;
use \app\models\Test;
class OtherTest extends \acer\test\Unit {
public function setUp() {
Test::config(array('connection' => $this->getConnection()));
@heptat
heptat / mapping.php
Created May 24, 2011 07:45
mapping
<?php
$unassigned_tests_records = Test::all(array('conditions' => array('id' => array('!=' => $test_ids))));
$unassigned_tests = $unassigned_tests_records->map(function($test) {
return array($test->id => $test->name);
}, array('collect' => false));
Array
(
[0] => Array
@heptat
heptat / redirect.php
Created July 25, 2011 13:35
redirect fn
<?php
/**
* Creates a redirect response by calling `render()` and providing a `'location'` parameter.
*
* @see lithium\net\http\Router::match()
* @see lithium\action\Controller::$response
* @param mixed $url The location to redirect to, provided as a string relative to the root of
* the application, a fully-qualified URL, or an array of routing parameters to be
* resolved to a URL. Post-processed by `Router::match()`.
@heptat
heptat / gist:1136813
Created August 10, 2011 13:35
all failing tests
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/candidate_tag.feature:110 # Scenario: Select all candidates and tag them
cucumber -p client-admin-all client_admin/candidate_test.feature:94 # Scenario: Select all candidates and assign a test form to them
cucumber -p client-admin-all client_admin/client_create.feature:34 # Scenario: Add a new client and be directed to the login page
cucumber -p client-admin-all client_admin/client_retrieve.feature:75 # Scenario: View a list of statistics relating to the client
172 scenarios (6 failed, 2 undefined, 164 passed)
@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)
@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: