Skip to content

Instantly share code, notes, and snippets.

View vasilakisfil's full-sized avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile
pi@raspberrypi:~ $ crystal
/opt/crystal/embedded/bin/crystal: /lib/arm-linux-gnueabihf/libtinfo.so.5: no version information available (required by /opt/crystal/embedded/bin/crystal)
/opt/crystal/embedded/bin/crystal: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /opt/crystal/embedded/bin/crystal)
@vasilakisfil
vasilakisfil / .eslintrc
Created April 27, 2017 14:07
eslint defaults..
{
"extends": "airbnb",
"env": {
"browser": true
},
"rules": {
"no-underscore-dangle": 0,
"class-methods-use-this": 0,
"arrow-body-style": 0,
"no-console": 0,
@vasilakisfil
vasilakisfil / test.rb
Created September 3, 2016 14:39
Ruby calling method performance
require 'benchmark/ips'
class Foo
def bar; end
end
foo = Foo.new
Benchmark.ips do |x|
x.config(:time => 5, :warmup => 2)
@vasilakisfil
vasilakisfil / user_serializer.rb
Last active September 2, 2016 21:38
How to include only links of relationships in JSONAPI (ActiveModelSerializers gem)
class Api::V1::UserSerializer < Api::V1::BaseSerializer
type :users
attributes :id, :name
has_many :microposts, serializers: Api::V1::MicropostSerializer do
link :self, '/api/v1/microposts'
end
end
@vasilakisfil
vasilakisfil / service.js
Created August 17, 2016 15:31
which one should we use ?
import Ember from 'ember';
export default Ember.Service.extend({
_observer1: Ember.observer('foobar', function() {
//something here
}).on('init'),
_observer2: Ember.on('init', Ember.observer('foobar', function() {
//something here
}))
});
@vasilakisfil
vasilakisfil / run.rb
Created May 22, 2016 08:06
Hack github's contribution history
require 'git'
require 'fileutils'
require 'date'
begin
FileUtils.rm_rf('.git/')
File.delete('myfile.out')
rescue Errno::ENOENT
end
@vasilakisfil
vasilakisfil / reshape_hash.rb
Last active April 13, 2016 08:56
Having fun with instance_exec in Ruby
class Hash
def reshape(binding)
new_hash = self.clone
new_hash.each{|k, v| new_hash[k] = (binding.instance_exec(&(v))) if v.is_a? Proc}
return new_hash
end
end
def foo_method
@vasilakisfil
vasilakisfil / benchmark.rb
Created March 30, 2016 15:26
Have fun with benchmarking in Ruby
require 'benchmark'
@i=0
def undefined_check
return @undefined_check += 2 if defined?(@undefined_check)
return @i += 1
end
@nil = nil

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:

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views