Skip to content

Instantly share code, notes, and snippets.

View wrozka's full-sized avatar

Paweł Pierzchała wrozka

View GitHub Profile
$provide.decorate('ngClick', function($delegate) {
var compile = $delegate.compile;
$delegate.compile = function($element, attrs) {
attrs.ngClick='__wrapResult__('+attrs.ngClick+')';
var link = compile($element, attrs)
return function($scope, element, attrs) {
$scope.__wrapResult__ = function(expression) {
return function() {
require 'bogus/rspec'
describe 'a bug' do
class NotificationListener
def auction_ended_no_bids(auction)
end
end
class Auction
end
<html ng-app='demo'>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script type="text/javascript">
function Outer($scope) {
$scope.bar = "bar from outer";
$scope.open = function(popup) {
$scope.$popup[popup].open();
};
@wrozka
wrozka / order_spec.rb
Last active December 20, 2015 03:09
rspec-mocks api on top of bogus.
require 'bogus/rspec'
class CallBuilder
attr_accessor :fake
def initialize(method, any_args, block, fake = nil)
@method = method
@fake = fake
@args = any_args
@block = block
@wrozka
wrozka / output
Created June 25, 2013 14:20
rbx problem
use_call: ; preds = %check_serial, %ip7
store i32 8, i32* %ip_pos49, !dbg !34
%push_const_fast = call %"struct.rubinius::Object"* @rbx_push_const_fast(%"struct.rubinius::State"* %state, %"struct.rubinius::CallFrame"* %call_frame30, %"struct.rubinius::ConstantCache"** inttoptr (i32 180003772 to %"struct.rubinius::ConstantCache"**)) nounwind readonly, !dbg !34
%null_check957 = icmp eq %"struct.rubinius::Object"* %push_const_fast, null, !dbg !34
br i1 %null_check957, label %ret_null47, label %check_active956, !dbg !34
continue953: ; preds = %continue955, %use_cache
%constant = phi %"struct.rubinius::Object"* [ %cached_value, %use_cache ], [ %push_const_fast, %continue955 ], !dbg !34, !rbx-classid !63
%stack_pos958 = getelementptr %"struct.rubinius::Object"** %stack31, i32 1, !dbg !34
store %"struct.rubinius::Object"* %constant, %"struct.rubinius::Object"** %stack_pos958, !dbg !34
@wrozka
wrozka / hardcoded.rb
Created January 31, 2013 14:43
Hardcoded dependencies
module HasClassName
def name
self.class.name
end
end
class UserFinder
include HasClassName
end
@wrozka
wrozka / parameters.rb
Created January 31, 2013 10:20
Automated manual dependency injection
require 'dependor'
require 'dependor/shorty' # to enable takes syntax
module HasClassName
def name
self.class.name
end
end
class UserFinder
@wrozka
wrozka / output.bash
Created January 27, 2013 11:09
Show me the case, when type safety get useful actually. ;p
wrozka@wrozka-home:~$ ruby parameters.rb
The combined names are: UserFinder and UserStatusReader
@wrozka
wrozka / img_convert.rb
Created April 19, 2012 14:10 — forked from shedd/img_convert.rb
convert html img tags to rails image_tag calls
#!/usr/bin/env ruby -Ku
require "nokogiri"
require "iconv"
# opens every file in the given dir tree and converts any html img tags to rails image_tag calls
#
# example usage:
# ruby convert.rb ~/my_rails_app/app/views
#
# ***be careful and backup before using this***