Skip to content

Instantly share code, notes, and snippets.

View mfilipe's full-sized avatar

Michel Filipe mfilipe

View GitHub Profile
@mfilipe
mfilipe / base.rb
Created August 21, 2013 19:31
Trying to create a monkey patch on ActionMailer
require 'mail'
require 'action_mailer/tmail_compat'
require 'action_mailer/collector'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/proc'
require 'active_support/core_ext/string/inflections'
require 'action_mailer/log_subscriber'
module ActionMailer #:nodoc:
@mfilipe
mfilipe / Gemfile
Last active December 25, 2015 04:39
uninitialized constant Bundler (NameError)
source 'http://rubygems.org/'
gem 'unicorn'
# group :app do
gem 'ruby-odbc', '0.99995'
gem 'sinatra'
#gem "sinatra-activerecord"
gem 'sinatra-contrib'
gem 'activerecord', '3.2.13'
@mfilipe
mfilipe / ubuntu-12.04 config
Created October 14, 2013 12:17
Connect to a Windows XP VM router PS.: IPEnableRouter activated in the Windows XP Registers
developer@ubuntu:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:54:3d:be
inet addr:192.168.21.128 Bcast:192.168.21.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe54:3dbe/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:169 errors:0 dropped:0 overruns:0 frame:0
TX packets:367 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22809 (22.8 KB) TX bytes:53298 (53.2 KB)
Interrupt:19 Base address:0x2000
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
@mfilipe
mfilipe / template.rb
Created April 21, 2016 17:57
ActiveRecord::RecordInvalid: Validation failed: User can't be of a different company
class Template < ActiveRecord::Base
belongs_to :company
belongs_to :template_category
belongs_to :user
validates :name, :subject, :body, :company, :template_category, :user, presence: true
validate :recommended_only_admin_user, :template_category_same_company, :user_same_company
private
@mfilipe
mfilipe / 20160419015541_change_recommended_default_of_templates.rb
Created May 20, 2016 03:53
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean ":default: false"
FactoryGirl.define do
factory :flow do
name "MyString"
daily_send nil
send_on_weekends false
actions [{'when': 'now', 'order': '1', 'template_id': '1234'}]
recipients [{'contact_id': '1234'},
{'first_name': 'Test', 'last_name': 'Last','email': 'user@test.com', 'business': 'Testing'}]
company
user { build :user, company: company }
#0 0x00007fff00000001 in ?? ()
#1 0x0000000000401434 in http_parser_execute (parser=0x609030, settings=0x7fffffffdc20,
data=0x7ffffffe4c10 "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nServer: Docker/1.10.2 (linux)\r\nDate: Mon, 07 Nov 2016 14:11:49 GMT\r\nTransfer-Encoding: chunked\r\n\r\n", len=147) at http_parser.c:777
#2 0x0000000000400b1a in main (argc=1, argv=0x7fffffffde18) at testhttp.c:77
- name: start service
service: name={{service_name}} state=started
when: service_status.stat.exists
register: start_result
tags:
- start
- name: update systemd files
shell: systemctl daemon-reload
when: start_result.failed and 'systemctl daemon-reload' in start_result.msg
reply = redisCommand(redis_conn, "SETEX inspect:%s %d %b", container_id, 60*2, inspect_result,
strlen(inspect_result));
// freeReplyObject(reply);
if (redisGetReply(redis_conn, reply)==REDIS_OK) {
logger_log("transmit_container_inspect joined\n");
freeReplyObject(reply);
} else {
logger_log("transmit_container_inspect redis error %d\n", __LINE__);
return -1;
}