Skip to content

Instantly share code, notes, and snippets.

View andrzejsliwa's full-sized avatar

Andrzej Śliwa andrzejsliwa

View GitHub Profile
myfun() ->
receive
{ello} ->
here I am...
myfun() ->
receive
{ello} ->
here I am...
@andrzejsliwa
andrzejsliwa / gist:1014973
Created June 8, 2011 18:11 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
#
# ActiveRecord SQL Logging on the Rails Console
# ---------------------------------------------
#
# Various blog posts out there show you how to log all SQL statements
# executed by ActiveRecord to STDOUT when you're in a Rails console:
#
# * http://robots.thoughtbot.com/post/159806033/irb-script-console-tips
# * http://weblog.jamisbuck.org/2007/1/8/watching-activerecord-do-it-s-thing
# * http://toolmantim.com/thoughts/system_wide_script_console_logging
@andrzejsliwa
andrzejsliwa / rspec-syntax-cheat-sheet.rb
Created July 6, 2011 19:15 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@andrzejsliwa
andrzejsliwa / LICENSE.txt
Created July 7, 2011 07:19 — forked from jed/LICENSE.txt
write contextual templates
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
task 'run' => :environment do
RubyProf.start
Bullet.enable=true
Bullet.start_request
20.times do
r = Rating.limit(20).includes(:comment => :post).to_a
end
Bullet.end_request
results = RubyProf.stop
@andrzejsliwa
andrzejsliwa / README.markdown
Created July 13, 2011 13:48 — forked from cooldaemon/README.markdown
Made a calculator using the yecc and leex.

Building from Source

% /path/to/reia/bin/leex calc_scan.xrl
% /path/to/reia/bin/yecc calc_parse.yrl
% erlc calc_scan.erl
% erlc calc_parse.erl
% erlc calc_eval.erl

How to Use

@andrzejsliwa
andrzejsliwa / lists_vs_func_vs_comp.erl
Created July 13, 2011 13:49 — forked from cooldaemon/lists_vs_func_vs_comp.erl
lists module vs func vs list comprehension.
-module(lists_vs_func_vs_comp).
-author('cooldaemon@gmail.com').
-export([test/0]).
test() ->
Seqs = lists:seq(0, 500000),
lists:foreach(
fun
({F, TargetName}) ->
@andrzejsliwa
andrzejsliwa / keep_state.erl
Created July 13, 2011 13:49 — forked from cooldaemon/keep_state.erl
Restore state on supervisor restart.
-module(keep_state).
-author('cooldaemon@gmail.com').
-export([test/0]).
test() ->
keep_state_sup:start_link(),
{} = keep_state_server:get_state(),
keep_state_server:put_state(foo),
foo = keep_state_server:get_state(),