Skip to content

Instantly share code, notes, and snippets.

View altherlex's full-sized avatar

Alther Alves altherlex

View GitHub Profile
@altherlex
altherlex / (dalli_memcache-client; rails3; ruby1.9; mongodb, Marshel).rb
Last active November 13, 2017 09:42
You are trying to cache a Ruby object which cannot be serialized to memcached.
Marshalling error for key '_my_session:1243f4a7a0c8d1dba363bc2ca7a246e8': singleton can't be dumped
You are trying to cache a Ruby object which cannot be serialized to memcached.
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/dalli-2.7.0/lib/dalli/server.rb:398:in `dump'
#Controller problem
session[:telefones] = Cliente.telefones
#Solution
session[:telefones] = Cliente.telefones.entries
@altherlex
altherlex / (passenger-4.0.37;nginx;RVM; passenger_ruby).rb
Last active August 29, 2015 13:56
How upgrade your Passenger 3 to 4; and one more environment in RVM; Rails3; Ruby1.9
# Head nginx.config
http {
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-4.0.37;
passenger_ruby /usr/local/bin/ruby;
passenger_default_user db2inst1;
#Optional:
# Permisson for db2inst1 in new gem passenger
chown root.db2grp1 -Rf /usr/local/lib/ruby/gems/1.8/gems/passenger-4.0.37
chmod 775 -Rf /usr/local/lib/ruby/gems/1.8/gems/passenger-4.0.37
@altherlex
altherlex / persistence.rb
Created April 22, 2014 18:01
Solution for IBM_DB in ISO-8859-1 - Problem with special character when update a object
#Overwrite update method from active_record/persistence.rb
# Solution for IBM_DB in ISO-8859-1 - Problem with special character when update a object
module ActiveRecord
module Persistence
def update(attribute_names = @attributes.keys)
klass = self.class
#No composite primary key
if !self.composite?

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@altherlex
altherlex / record-path-link_to_helper.rb
Last active August 29, 2015 14:01
Change the record path in link_to for RAILS3
@altherlex
altherlex / description_component.rb
Last active February 13, 2017 20:23
Simple_form in show
#config/initializers/simple_form/description_component.rb
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups
module Description
# Name of the component method
def desc(wrapper_options = nil)
object.send(attribute_name) if @builder.instance_variable_get('@lookup_action') == :show
end
end
@altherlex
altherlex / select_with_ISO-params.rb
Last active August 29, 2015 14:07
Tests for select query with ISO-8859-1 param in where like
# Issue IBMDB
#https://github.com/ibmdb/ruby-ibmdb/issues/1
# test#1
db = IBM_DB.connect "DBTESTE", 'teste', 'bala123'
sql2 = "SELECT glb.books.* FROM glb.books WHERE author = '?'"
st = IBM_DB.prepare db, sql2 #, IBM_DB::SQL_PARAM_INPUT, IBM_DB::SQL_CHAR
value = 'Júlio Verne'
IBM_DB.bind_param st, 1, 'value'
IBM_DB.execute st
@altherlex
altherlex / tips_for_sentry_use.rb
Created November 18, 2014 13:04
Sentry version 6.3.0 doesn't work with sentry-raven master (0.12.0)
#If you use Sentry (6.3.0)
#
#You have use gems for your RailsApp in such versions:
gem "sentry-raven", :tag=>'0.7.1',:git => "https://github.com/getsentry/raven-ruby.git"
gem 'hashie' , '=2.1.2'
@altherlex
altherlex / pdfwriter_extensions.rb
Last active August 29, 2015 14:15
PDF::Writter for Ruby 1.9 and DB in ISO-8859-1: convert database info from ISO-8859-1 to UTF-8; for rigth show in PDF
#config\initializers\pdfwriter_extensions.rb
CONVERTER = Iconv.new( 'ISO-8859-1//IGNORE//TRANSLIT', 'utf-8')
module PDF
class Writer
# for fixed text (labels in general): It isn't necessary! (Obsolete)
alias_method :old_text, :text
def text(textto, options = {})
#old_text(CONVERTER.iconv(textto), options)
old_text(textto, options)
@altherlex
altherlex / first-powershell.ps1
Created February 27, 2015 13:59
PowerSheel: How execute a scrip file in windows8 (The new Batch Files)
# into file first-powershell.ps1
Get-Process |ConvertTo-HTML| Out-File "Processos-mane.html"
# line command
$ Get-ExecutionPolicy -list
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined