Skip to content

Instantly share code, notes, and snippets.

View vasilakisfil's full-sized avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile
@dklisiaris
dklisiaris / rails-boilerplate.md
Last active August 18, 2017 05:58
A manual setup for a typical rails 4.x. app with bootstrap layout, devise authentication, rspec testing framework with capybara and git version control.

Setup a new project and database.

Create a new rails app named app_name without Test::Unit and with mysql database:

rails new app_name -T -d mysql

or an app without Test::Unit and with postgresql database:

rails new app_name -T -d postgresql

or without Test::Unit and with the default sqlite:

// {{ radio-button name='dish' value='spam' groupValue=selectedDish selectedAction='testAction' }} Spam
// {{ radio-button name='dish' value='eggs' groupValue=selectedDish }} Eggs
//
/*
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: [ 'checked', 'name', 'type', 'value' ],
@jvenezia
jvenezia / rails_mailer_structure.md
Last active January 4, 2023 13:44
Rails mailer structure

Rails mailer structure

Your application is growing, and you are starting to have a complex mailing system: notification emails, retention emails, misc user emails, admin emails, etc...

It's time to clean up your mailers !

Existing mailer

You may already have a single mailer, responsible of every emails, like this one:

@vasilakisfil
vasilakisfil / run.sh
Last active February 16, 2024 09:05
New linux machine setup
#install essential stuff
sudo apt-get install build-essential autoconf locate
sudo apt-get install git guake zsh curl vim vim-gtk3 postgresql-client \
postgresql postgresql-contrib redis golang direnv tmux bat ripgrep fzf
curl -L http://install.ohmyz.sh | sh
chsh -s /bin/zsh
zsh
#edit pg_hba.conf
@tadast
tadast / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@havenwood
havenwood / arity_range.rb
Last active August 29, 2015 13:56
Ask a method, lambda or proc for the range of arguments it can be called with from minimum to maximum.
module ArityRange
def arity_range
args = parameters.map &:first
req = args.count :req
opt = args.include?(:rest) ? Float::INFINITY : args.count(:opt)
keyreq = args.count :keyreq
keyopt = args.include?(:keyrest) ? Float::INFINITY : args.count(:key)
@mpeteuil
mpeteuil / rubocop_pre_commit_hook
Created August 3, 2013 17:44
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@alex-zige
alex-zige / gist:5795358
Last active June 8, 2023 07:49
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 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. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

@d-mart
d-mart / domain_validator.rb
Created October 4, 2012 21:34 — forked from rietta/domain_validator.rb
Rails 3 Bare Domain Validator
#
# Domain Validator by Frank Rietta
# (C) 2012 Rietta Inc. All Rights Reserved.
# Licensed under terms of the BSD License.
#
# To use in a validation, add something like this to your model:
#
# validates :name, :domain => true
#
class DomainValidator < ActiveModel::EachValidator