Skip to content

Instantly share code, notes, and snippets.

View iagopiimenta's full-sized avatar
🏠
Working from home

Iago Pimenta iagopiimenta

🏠
Working from home
View GitHub Profile

Mysql2::Error: Specified key was too long; max key length is 767 bytes

You might get this error with InnoDB tables on MariaDB < 10.2.2, MySQL < 5.7. Although, this error might be also triggered on newer versions if you switch to COMPACT row format.

In the abovementioned releases the default InnoDB row format is COMPACT. With this format the maximum index prefix length is [767 bytes][max-index-prefix]. The default character set is [latin1][def-charset], but if you use

@iagopiimenta
iagopiimenta / blowfish.rb
Created March 24, 2021 21:11
Blowfish Encryption using ECB with short keys compatible with http://sladex.org/blowfish.js/ext/blowfish.js
require 'openssl'
require 'base64'
class Blowfish
def initialize(key, algorithm = 'bf-ecb')
@key = key
@algorithm = algorithm
end
def encrypt(data)
@iagopiimenta
iagopiimenta / demo.html
Last active December 11, 2017 15:00
Firefox - ReDoc crash with Newrelic RPM JS-agent
<!DOCTYPE html>
<html>
<head>
<title>DEMO</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="prefetch" href="https://rebilly.github.io/RebillyAPI/swagger.json">
<script type="text/javascript">
@iagopiimenta
iagopiimenta / Dockerfile
Created May 31, 2017 15:38
Dockerfile: Ruby 2.3.3 + nodejs + yarn + locales en_US.UTF-8
FROM ruby:2.3.3
# change this to force update node minor and patch version
ENV NODE_DATE_INSTALL 20170519
# change this to update node major version
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
RUN apt-get update &&\
# add support to unicode chars from keyboard: ç,ã,ô:
@iagopiimenta
iagopiimenta / start
Last active May 31, 2017 15:39
dokcer-compose: command: ./script/start bundle exec rails s -p 3000 -b 0.0.0.0
#!/usr/bin/env bash
# if ! [ -x "$(command -v bower)" ]; then
# npm install -g bower
# fi
mkdir -p tmp/pids
if ! [ -z "$REMOVE_FILE" ]
then
@iagopiimenta
iagopiimenta / Dockerfile
Created January 31, 2017 23:53
Dockerfile Ruby 2.3.3 with UTF-8 UNICODE support and without ROOT
FROM ruby:2.3.3
RUN apt-get update &&\
# add support to unicode chars from keyboard: ç,ã,ô:
apt-get install -y locales \
# JavaScript runtime to uglifier:
nodejs \
# rails dbconsole
# psql \
# Required by rails-erd
@iagopiimenta
iagopiimenta / accessed_fields.rb
Created October 30, 2016 23:03
Mongoid 3.1.6 - Rails 3.2 - accessed_fields
# lib/accessed_fields.rb
module AccessedFields
def self.included(klass)
klass.extend(ClassMethods)
return unless klass.respond_to?(:fields)
klass.fields.keys.each do |field_name|
klass.wrap_default_method(field_name)
end
@iagopiimenta
iagopiimenta / monkey_patch_rails_parameters.rb
Created February 18, 2016 14:48
Rails 4: Strong parameters: allow hashes
module ActionController
class Parameters
# See https://github.com/rails/rails/blob/v4.2.5.1/actionpack/lib/action_controller/metal/strong_parameters.rb#L562
def hash_filter(params, filter)
filter = filter.with_indifferent_access
# Slicing filters out non-declared keys.
slice(*filter.keys).each do |key, value|
next unless value
@iagopiimenta
iagopiimenta / readme.md
Created October 9, 2015 18:06
Git repo readme

Git - the stupid content tracker

git can mean anything, depending on your mood.

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • "global information tracker": you're in a good mood, and it actually
@iagopiimenta
iagopiimenta / .tmux.conf
Created September 29, 2015 16:57
.tmux.conf
#
# Tmux configuration
#
# See:
# http://github.com/brandur/tmux-extra
#
# C-b is not acceptable -- Vim uses it
# set-option -g prefix C-b
# bind-key C-b next-window