Skip to content

Instantly share code, notes, and snippets.

View thelinuxlich's full-sized avatar
🐉
Here be dragons

Alisson Cavalcante Agiani thelinuxlich

🐉
Here be dragons
View GitHub Profile
@thelinuxlich
thelinuxlich / query.js
Last active August 29, 2015 14:05
query with during
r.table("errors").filter(
{
client_id: "1",
properties: {message: "Uncaught Error: Error calling method on NPObject."}
}
).filter(r.row("created_at").during(r.now().sub(24 * 60 * 60),r.now()));
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/jruby/bin/jruby extconf.rb
NotImplementedError: C extension support is not available
(root) at /opt/jruby/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:926
(root) at /opt/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
require at /opt/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.5'
# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
@thelinuxlich
thelinuxlich / gist:8140670a2f3967873dc7
Created August 28, 2014 21:43
error on rake db:migrate
01:53:59 {master} ~/yebo$ GEM_HOME=~/.gem/jruby jruby -S rake db:migrate
rake aborted!
NameError: undefined method 'ransack' for class '#<Class:0x9c9245>'
/home/thelinuxlich/.gem/jruby/gems/ransack-1.1.0/lib/ransack/adapters/active_record/base.rb:7:in `extended'
/home/thelinuxlich/.gem/jruby/gems/ransack-1.1.0/lib/ransack/adapters/active_record.rb:2:in `(root)'
/home/thelinuxlich/.gem/jruby/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:1:in `(root)'
/home/thelinuxlich/.gem/jruby/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/home/thelinuxlich/.gem/jruby/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/thelinuxlich/.gem/jruby/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
/home/thelinuxlich/.gem/jruby/gems/ransack-1.1.0/lib/ransack.rb:22:in `(root)'
LoadError: load error: /home/thelinuxlich/yebo/config/environment -- java.lang.ClassCastException: org.jruby.parser.LocalStaticScope cannot be cast to org.jruby.parser.IRStaticScope
@thelinuxlich
thelinuxlich / base.rb
Created August 28, 2014 22:08
ransack hack
module Ransack
module Adapters
module ActiveRecord
module Base
def self.extended(base)
if !base.method_defined? :search
alias_method :search, :ransack
end
base.class_eval do
@thelinuxlich
thelinuxlich / database.rb
Created September 4, 2014 23:12
database.rb
Rails.application.config.after_initialize do
ActiveRecord::Base.connection_pool.disconnect!
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
puts config
config['reaping_frequency'] = 10 # seconds
ActiveRecord::Base.establish_connection(config)
@thelinuxlich
thelinuxlich / puma.rb
Created September 4, 2014 23:13
puma.rb
threads 3, 3
workers 2
on_worker_boot do
require "active_record"
require "erb"
cwd = File.dirname(__FILE__)+"/.."
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
configuration = YAML.load(ERB.new(File.read("#{cwd}/config/database.yml")).result)
ActiveRecord::Base.establish_connection(configuration[ENV["RAILS_ENV"]])
var r = require('rethinkdbdash')();
setInterval(function() {
r.table("logs").insert({
date: r.now()
}).run({noreply: true})
, 1000)
r.table("logs").changes().run().then(function(feed) {
@thelinuxlich
thelinuxlich / query.js
Created September 22, 2014 20:51
query.js
var field = ["properties","type"],
value = "event";
// ... some query
.filter(function(row) {
var _row;
if(Array.isArray(field)) {
for(i = 0; i < field.length; i++) {
_row = row(field[i]);
}