Skip to content

Instantly share code, notes, and snippets.

Jan Dudek jdudek

Block or report user

Report or block jdudek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8c63abd5054d9a1db9e2
~/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 Sep 15, 2010
Doctrine_Pager extension that handles multiple queries
View Multi.php
<?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 Nov 24, 2010
Test validations in ActiveRecord
View user_spec.rb
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 Mar 15, 2011
Session isolation in Capybara/Steak tests
View sessions_controller.rb
class SessionsController < ApplicationController
def create
session[:created] = true
render :text => "Session created"
end
def check
if session[:created]
render :text => "Session exists"
else
View deferred.html
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script src="deferred.js" type="text/javascript"></script>
</head>
<body></body>
</html>
View import.rb
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/
View tags.rb
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
View tags.rb
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 Sep 13, 2011
Testing REST API using BBQ
View game_api_test.rb
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)
View game_screen_controller_spec.js.coffee
test = (suite) ->
self = {}
steps = []
last = null
run = (suite, steps) ->
return if steps.length == 0
[step, msg, fn] = steps.shift()
if step == describe
describe.call suite, msg, ->
You can’t perform that action at this time.