Skip to content

Instantly share code, notes, and snippets.

Robert Pankowecki paneq

Block or report user

Report or block paneq

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
@paneq
paneq / links.md
Last active Dec 30, 2018
My (Robert Pankowecki's) favourite books, presentations, blog-posts and articles related to Software Development in the whole Internet (that I remembered of)
View handler.rb
class MyCommandHandler
def initialize
make_threadsafe_by_stateless
end
def call(cmd)
local_var = cmd.something
output(local_var)
end
@paneq
paneq / ConstToMethodRewriter.rb
Created Sep 13, 2018
Rewrite constant to a method
View ConstToMethodRewriter.rb
require 'pry'
require 'parser'
require 'parser/current'
class ConstToMethodRewriter < ::Parser::Rewriter
def on_casgn(node)
_, const_name, *args = node.children
replace_range = node.location.expression
const_value = args.first.location.expression.source
@paneq
paneq / log.txt
Created Mar 27, 2018
monit pool start brings back only dead nodes, keeps alive working
View log.txt
~/d/project (feature/delayed_job_pool|✚3…) $ cat tmp/pids/delayed_job.0.pid
14702
~/d/project (feature/delayed_job_pool|✚3…) $ cat tmp/pids/delayed_job.1.pid
14704
~/d/project (feature/delayed_job_pool|✚3…) $ ps aux | grep delayed
rupert 14702 72.9 2.9 4865820 481384 ?? R 9:43AM 3:25.55 delayed_job.0
rupert 14704 0.0 2.8 4839192 467044 ?? S 9:43AM 3:26.31 delayed_job.1
rupert 15205 0.0 0.0 4267752 360 s005 R+ 10:18AM 0:00.00 grep --color=auto delayed
~/d/project (feature/delayed_job_pool|✚3…) $ kill -9 14702
@paneq
paneq / rails_erb_syntax_check.rb
Last active Jan 9, 2018 — forked from arika/rails_erb_syntax_check.rb
Rails(Action View) ERB template syntax checker
View rails_erb_syntax_check.rb
require 'action_view'
require 'tmpdir'
require 'fileutils'
require 'optparse'
def check_syntax(path, options = {})
erb = content(path)
code = ruby_code(erb)
eval("BEGIN { puts('ok'); return true }; #{code}", nil, path, 0)
@paneq
paneq / serializer_benchmarks.rb
Created Jan 13, 2016 — forked from aishfenton/serializer_benchmarks.rb
Performance comparison of different ruby serializer methods
View serializer_benchmarks.rb
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'
@paneq
paneq / explain.txt
Created Sep 3, 2015
mysql using index based on attribute type
View explain.txt
mysql> EXPLAIN SELECT `my_table_name_xxxxxxxxxxxxx`.* FROM `my_table_name_xxxxxxxxxxxxx` WHERE `my_table_name_xxxxxxxxxxxxx`.`order_id` = 2015522 LIMIT 1;
+----+-------------+-----------------------------+------+-----------------------------------------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------------------+------+-----------------------------------------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | my_table_name_xxxxxxxxxxxxx | ALL | index_my_table_name_xxxxxxxxxxxxx_on_order_id | NULL | NULL | NULL | 280511 | Using where |
+----+-------------+-----------------------------+------+-----------------------------------------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)
mysql> EXPLAIN SELECT `my_table_name_xxxxxxxxxxxxx`.* FROM `my_table_name_xx
@paneq
paneq / low_level.rb
Last active Aug 29, 2015
elastic search category filter
View low_level.rb
client = Elasticsearch::Client.new host: 'localhost:9200', logger: Rails.logger
client.indices.create({
index: "businesses",
body: {
settings: {},
mappings: {
"business" => {
properties:{
name: {:type=>"string", index: "not_analyzed"}, # you probably need different index type depending on what kind of queries there are
View 1.rb
# keep in one file
class Whatever
class A
def self.interface_method
end
end
class B
def self.interface_method
end
@paneq
paneq / log.txt
Created Dec 25, 2014
ubuntu 12.04 + ruby 2.2.0
View log.txt
==> p: Last 10 log lines:
==> p: compiling object_tracing.c
==> p: compiling objspace.c
==> p: linking shared-object objspace.so
==> p: make[2]: Leaving directory `/tmp/ruby-build.20141225212618.1716/ruby-2.2.0/ext/objspace'
==> p: linking shared-object date_core.so
==> p: make[2]: Leaving directory `/tmp/ruby-build.20141225212618.1716/ruby-2.2.0/ext/date'
==> p: linking shared-object nkf.so
==> p: make[2]: Leaving directory `/tmp/ruby-build.20141225212618.1716/ruby-2.2.0/ext/nkf'
==> p: make[1]: Leaving directory `/tmp/ruby-build.20141225212618.1716/ruby-2.2.0'
You can’t perform that action at this time.