Skip to content

Instantly share code, notes, and snippets.

View vasilakisfil's full-sized avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile

Rails Rspec APIs Testing Notes

Folders Structure

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

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 / android_debug.h
Created March 31, 2012 10:47
C++ code (the patch is the last file )
/***************************************************************************
** This file is part of the generic algorithm library Wiselib. **
** Copyright (C) 2008,2012 by the Wisebed (www.wisebed.eu) project. **
** **
** The Wiselib is free software: you can redistribute it and/or modify **
** it under the terms of the GNU Lesser General Public License as **
** published by the Free Software Foundation, either version 3 of the **
** License, or (at your option) any later version. **
** **
** The Wiselib is distributed in the hope that it will be useful, **
@vasilakisfil
vasilakisfil / Android.mk
Created March 31, 2012 10:49
Java code ( the testing app)
# build file written to describe the C and C++ source files to the Android NDK
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := debugTest
LOCAL_CXXFLAGS := -W
LOCAL_SRC_FILES := debug_test.cpp
#This definition is needed by wiselib
LOCAL_C_INCLUDES := /home/vasilakis/Development/wiselib/wiselib.testing/ \
/home/vasilakis/Development/wiselib/wiselib.stable/
@vasilakisfil
vasilakisfil / main_map.js
Created November 29, 2012 11:34
The code in lines 15-37 does not return all the markers...
var GMAPS = window.GMAPS || {};
GMAPS.mainMap = function() {
var map;
var infowindow = new google.maps.InfoWindow();
var jsonObject = {};
function addMarkers() {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "/home.json", true );
xhr.onreadystatechange = function () {
var GMAPS = window.GMAPS || {};
GMAPS.mainMap = function() {
var map;
var infowindow = new google.maps.InfoWindow();
var jsonObject = {};
function addMarkers() {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "/home.json", true );
xhr.onreadystatechange = function () {
@vasilakisfil
vasilakisfil / users_controller.rb
Last active November 16, 2015 22:58
restfull api in rails
class Api::V1::UsersController < Api::V1::BaseController
skip_before_filter :authenticate_user, only: [:create, :resetpassword]
def index
users = policy_scope(User)
render json: users, each_serializer: Api::V1::UserSerializer
end
def resetpassword
@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
@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 / 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