Skip to content

Instantly share code, notes, and snippets.

View costis's full-sized avatar
🎯
Focusing

Costis Panagiotopoulos costis

🎯
Focusing
View GitHub Profile
@costis
costis / gist:4079034
Created November 15, 2012 14:58
RVM install ruby-perf (falcon patches)
rvm reinstall 1.9.3-perf --patch falcon --force-autoconf -j 3
@costis
costis / integrated_docs.rb
Created November 21, 2012 13:14 — forked from mattwynne/integrated_docs.rb
Integrated documentation for Ruby
# For context, this was inspired by the RubyRogues podcast #79 where they talked about
# documentation in Ruby, and specifically grumbled quite a bit about the failings of RDoc.
#
# http://rubyrogues.com/079-rr-documenting-code/
#
# As someone who's spent a lot of time using an IDE for programming C# and Java, I think
# Ruby could do a lot better at putting documentation at our fingertips as we program.
#
# Maybe making the documentation part of the structure of the code would facilitate this?
#
@costis
costis / gist:4125937
Created November 21, 2012 16:42
Modify Git history
# replace a string occuring to all .yml documents, everywhere in history.
# note: -i "" in sed was needed for OSX. Normally I would write 'sed -i -e "s/foo/bar/g"'.
git filter-branch --tree-filter 'find . -name "*.yml" -exec sed -i "" -e "s/some-config-parameter/new-config-parameter/g" {} \;' HEAD
# the above will create an internal git backup. Delete it with the following command:
git update-ref -d refs/original/refs/heads/master
# create a script with the following contents to change commiter/author name & email.
#!/bin/sh
@costis
costis / gist:4131738
Created November 22, 2012 15:34
Make ruby fly
# From:http://alisnic.net/blog/making-your-ruby-fly/
# into ~/.rvmrc
rvm_configure_env=(CFLAGS="-march=core2 -O2 -pipe -fomit-frame-pointer")
# and then
rvm install 1.9.3-turbo --patch falcon
# or better
rvm get head
@costis
costis / gist:4169119
Last active October 13, 2015 08:38
git submodules

How to manage git submodules

Add new

git submodule add http://blah.blha.com/project.git a_project_path
git add *
git commit -m "adding a submodule"

Update

cd a_project_path

git pull

@costis
costis / ctags_for_ruby.txt
Created January 4, 2013 14:10
Ctags creation for Ruby projects
# Scan all installed gems - very slow
ctags --extra=+f --exclude=.git --exclude=log -R * gem environment gemdir/gems/*
# Scan only gems from current Gemfile
bundle list --paths=true | xargs ctags --extra=+f --exclude=.git --exclude=log -R *
require 'factory_girl_rails'
require 'rspec'
require 'rspec-rails'
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example)
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user`
def reload_factories!
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences
# FactoryGirl.instance_variable_set(:@sequences, nil)
@costis
costis / gist:4572756
Created January 19, 2013 13:45
Rails Engines producing RSpec
class Engine < ::Rails::Engine
isolate_namespace
config.generators do |g|
g.test_framework :rspec
g.integration_tool :rspec
end
end
@costis
costis / gist:4643072
Created January 26, 2013 16:12
MYSQL create UTF8 database

CREATE DATABASE mydb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

@costis
costis / sandi_metz_rules_for_developers.md
Last active December 12, 2015 09:49 — forked from sdball/sandi_metz_rules_for_developers.md
Sandi Metz’ rules for developers

Sandi Metz’ rules for developers

  1. Your class can be no longer than a hundred lines of code.
  2. Your methods can be no longer than five lines of code
  3. You can pass no more than four parameters and you can't just make it one big hash.
  4. In your controller, you can only instantiate one object, to do whatever it is that needs to be done.
  5. Your view can only know about one instance variable.
  6. Your Rails view should only send messages to that object i.e., no Demeter violations.[ "thunder dome principal". Translated: one model in, one model out! ]
  7. Rules are meant to be broken if by breaking them you produce better code. [ ...where "better code" is validated by explaining why you want to break the rule to someone else. ]