Skip to content

Instantly share code, notes, and snippets.

View jdudek's full-sized avatar

Jan Dudek jdudek

View GitHub Profile
~/tmp/git-example (master) $ git log
fc8f07f 2014-06-25 15:25:14 +0200 | A (HEAD, master) [Jan Dudek]
530ef46 2014-06-25 15:08:41 +0200 | initial commit [Jan Dudek]
~/tmp/git-example (master) $ git log b
86c2a22 2014-06-25 15:25:49 +0200 | B (b) [Jan Dudek]
530ef46 2014-06-25 15:08:41 +0200 | initial commit [Jan Dudek]
~/tmp/git-example (master) $ git log c
773f7a1 2014-06-25 15:26:13 +0200 | C (c) [Jan Dudek]
@jdudek
jdudek / Multi.php
Created September 15, 2010 11:09
Doctrine_Pager extension that handles multiple queries
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@jdudek
jdudek / user_spec.rb
Created November 24, 2010 21:50
Test validations in ActiveRecord
require 'spec_helper'
module ActiveModel
class Errors
def error_names
@_error_names ||= { }
end
def add_with_save_names(attribute, message = nil, options = {})
message ||= :invalid
@jdudek
jdudek / sessions_controller.rb
Created March 15, 2011 17:05
Session isolation in Capybara/Steak tests
class SessionsController < ApplicationController
def create
session[:created] = true
render :text => "Session created"
end
def check
if session[:created]
render :text => "Session exists"
else
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script src="deferred.js" type="text/javascript"></script>
</head>
<body></body>
</html>
csv = File.open("index.csv", "w")
Dir.glob("in/*").each_with_index do |path, i|
file = path.gsub("in/", "").gsub(/\.wav$/, "")
index = i + 1
difficulty = case file
when /^latwe/
1
when /^srednie/
create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.string "taggable_type", :default => ""
t.integer "taggable_id"
end
class Post
has_many :taggins, :polymorphic => true
def tags
create_table "tags", :force => true do |t|
t.string "name", :default => ""
end
create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.string "taggable_type", :default => ""
t.integer "taggable_id"
end
@jdudek
jdudek / game_api_test.rb
Created September 13, 2011 00:26
Testing REST API using BBQ
require File.dirname(__FILE__) + "/../test_helper"
class GameApiTest < Bbq::TestCase
background do
@admin = TestUser.new
@admin.roles(:admin)
@admin.prepare_game_data
@client = TestClient.new
@client.extend(TestClient::GameClient)
@jdudek
jdudek / testing-rich-client-v2-pub.coffee
Created November 24, 2011 22:27
A few thoughts on testing rich-client applications (meet.js)
# A few thoughts on testing rich-client applications
# Jan Dudek, Arkency
# We've created a game that has some animations, uses Facebook API. Almost no rendering on the server. Client-server communication through JSON REST API.