Skip to content

Instantly share code, notes, and snippets.

Tomasz Stachewicz tomash

Block or report user

Report or block tomash

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 keybase.md

Keybase proof

I hereby claim:

  • I am tomash on github.
  • I am tomash (https://keybase.io/tomash) on keybase.
  • I have a public key ASDJs7kpi0pvnx_LOk2aJGr0PZ0An9aWW_t6ozuxV4jHewo

To claim this, I am signing this object:

View orders.rake
namespace :orders do
desc "make orders abandoned for a few days as cancelled"
task :cleanup => :environment do
Order.abandoned_but_not_marked.each do |order|
begin
order.cancellation_code = "abandoned"
order.save!
rescue => e
$stderr.puts "Could not mark as cancelled and save! order ##{order.id}"
$stderr.puts e.message
@tomash
tomash / inheritance_modules_callbacks.rb
Last active Dec 18, 2015
Class variable defined on parent class level being set on the parent class level. Looks like a Ruby-powered "feature" of STI.
View inheritance_modules_callbacks.rb
# seems to work properly, i.e. exporting_message callback does not pollute
require 'active_support/callbacks'
module Exportage
def self.included(base)
base.class_eval do
set_callback :save, :before, :exporting_message
def exporting_message
puts "exporting..."
end
@tomash
tomash / address_sanity_check.rb
Created Nov 23, 2012
fix order addresses #438136
View address_sanity_check.rb
# sanity checking
users_with_multiple_addresses = []
User.all.each do |user|
addresses = Address.where(:addressable_type => 'User', :addressable_id => user.id)
if(addresses.count > 1)
users_with_multiple_addresses << user
end
end
@tomash
tomash / dlabeki.user.js
Created Nov 23, 2012
DlaBeki: userscript dodający pasek "czytam dla beki" na prawicowych sajtach
View dlabeki.user.js
// ==UserScript==
// @name Czytam Prawicowe Strony Dla Beki
// @description Pokazuje pasek "czytam dla beki" na mocno prawicowych serwisach
// @icon http://tomash.wfb-pol.org/userscripts/dlabeki/icon32.png
// @icon64 http://tomash.wfb-pol.org/userscripts/dlabeki/icon128.png
// @version 1.0.0
// @license MIT
// @include http://niezalezna.pl/*
// @include http://*.niezalezna.pl/*
// @include http://naszeblogi.pl/*
@tomash
tomash / app.d
Created Jun 4, 2012
vibe.d vs sinatra, a meaningless microbenchmark
View app.d
// microwebapp microbenchmark, D/vibe version
import vibe.d;
void index(HttpServerRequest req, HttpServerResponse res)
{
res.renderCompat!("index.dt")();
}
void show(HttpServerRequest req, HttpServerResponse res)
@tomash
tomash / with rails_admin.log
Created Nov 30, 2011
memprof results - looking for memory leak
View with rails_admin.log
6733 /app/shared/bundle/ruby/1.8/gems/newrelic_rpm-3.1.0/lib/new_relic/agent/transaction_sampler.rb:106:String
6272 /app/shared/bundle/ruby/1.8/gems/activemodel-3.0.9/lib/active_model/attribute_methods.rb:297:__node__
5060 /app/shared/bundle/ruby/1.8/gems/haml-3.1.2/lib/haml/util.rb:241:String
3136 /app/shared/bundle/ruby/1.8/gems/activemodel-3.0.9/lib/active_model/attribute_methods.rb:296:__node__
3036 /app/shared/bundle/ruby/1.8/gems/haml-3.1.2/lib/haml/util.rb:241:Array
2476 /app/releases/20110722072656/app/helpers/application_helper.rb:42:String
1991 /app/shared/bundle/ruby/1.8/gems/activerecord-3.0.9/lib/active_record/attribute_methods/read.rb:80:__node__
1568 /app/shared/bundle/ruby/1.8/gems/activemodel-3.0.9/lib/active_model/attribute_methods.rb:298:__node__
1116 /app/shared/bundle/ruby/1.8/gems/activerecord-3.0.9/lib/active_record/attribute_methods/write.rb:14:__node__
1012 /app/shared/bundle/ruby/1.8/gems/haml-3.1.2/lib/haml/util.rb:248:Array
@tomash
tomash / Gemfile
Created Nov 4, 2011
no rails in gemfile, works as rails app!
View Gemfile
source 'http://rubygems.org'
gem "mongoid"
gem "bson_ext"
gem 'mongoid_denormalize'
gem "fabrication"
gem 'httparty'
gem 'acts_as_api'
gem "httparty"
@tomash
tomash / twitter_worker.rb
Created Sep 29, 2011
twitter worker: multiple twitter streams
View twitter_worker.rb
require "daemon_spawn"
require "socket"
require "tmpdir"
require 'twitter/json_stream'
require 'json'
require "./config/environment"
# todo: write tests
class TwitterWorker
@tomash
tomash / gist:957184
Created May 5, 2011
output of backup's rspec
View gist:957184
tomek@asus-laptop:~/ruby_apps/backup$ bundle exec rspec spec/
1) Backup::Encryptor::OpenSSL when a block is provided
Failure/Error: encryptor.password.should == "my_secret_password"
expected: "my_secret_password"
got: nil (using ==)
# ./spec/encryptor/open_ssl_spec.rb:37
2) Backup::Encryptor::OpenSSL when a block is provided
You can’t perform that action at this time.