Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Zubkov sekrett

View GitHub Profile
View gist:290f927ca0dccfee00f50ff353b621c5
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/lib/mysql2/mysql2.so: [BUG] Segmentation fault at 0x00000812970f4f
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-freebsd10.2]
-- Control frame information -----------------------------------------------
c:0048 p:-4319933836 s:0206 e:000205 TOP [FINISH]
c:0047 p:---- s:0204 e:000203 CFUNC :require
c:0046 p:0132 s:0200 e:000199 METHOD /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55
c:0045 p:0282 s:0189 e:000188 TOP /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/lib/mysql2.rb:31 [FINISH]
c:0044 p:---- s:0186 e:000185 CFUNC :require
c:0043 p:0103 s:0182 e:000181 RESCUE /opt/chef/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133
View url_resolver.rb
require 'uri'
require 'net/http'
require 'openssl'
class UrlResolver
def self.resolve(uri_str, agent = 'curl/7.43.0', max_attempts = 10, timeout = 10)
attempts = 0
cookie = nil
until attempts >= max_attempts
View devise.ru.yml
# Русский перевод для https://github.com/plataformatec/devise/tree/v3.2.4
# Другие переводы на http://github.com/plataformatec/devise/wiki/I18n
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись подтверждена."
send_instructions: "В течение нескольких минут Вы получите письмо с инструкциями по подтверждению Вашей учётной записи."
send_paranoid_instructions: "Если Ваш адрес email есть в нашей базе данных, то в течение нескольких минут Вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
@sekrett
sekrett / positioned.rb
Created Jan 12, 2012
Positioned module
View positioned.rb
# Example:
#
# class Page < ActiveRecord::Base
# include Positioned
# end
module Positioned
def self.included model_class
model_class.class_eval do
before_save :set_position
View nokogiri
# using rvm with ruby-1.9.2-p290
# latest version 2.7.8
brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
@sekrett
sekrett / gist:804312
Created Jan 31, 2011
Split to directories
View gist:804312
$dir1 = sprintf("%04d", (int) ($id / 1000000));
$dir2 = sprintf("%03d", (int) (($id % 1000000) / 1000));
$dir3 = sprintf("%03d", (int) ($id % 1000));
View sanitize.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'active_record'
require 'sanitize'
ActiveRecord::Base.establish_connection(YAML::load(File.open("./database.yml"))['production'])
class Manufacturer < ActiveRecord::Base