Skip to content

Instantly share code, notes, and snippets.

# https://github.com/elastic/elasticsearch-rails/pull/361
module Elasticsearch
module Model
module Adapter
# The default adapter for models which haven't one registered
#
module Sequel
Adapter.register(
self,
lambda do |klass|
@JRubyMethod(meta = true)
public static IRubyObject for_fd(ThreadContext context, IRubyObject _klass, IRubyObject _fileno) {
Ruby runtime = context.runtime;
int fileno = (int)_fileno.convertToInteger().getLongValue();
RubyClass klass = (RubyClass)_klass;
final RubyClass UNIXSocket = runtime.getClass("UNIXSocket");
RubyUNIXSocket unixSocket = (RubyUNIXSocket)(Helpers.invoke(context, UNIXSocket, "allocate"));
try {
// begin hack
# Sequel assoc_ids / assoc_ids=
module SequelAssociationIds
def one_to_many(name, *args, &block)
super
create_ids_accessor(name)
end
def many_to_many(name, *args, &block)
super
create_ids_accessor(name)
NoMethodError: undefined method `[]' for nil:NilClass
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:751:in `type_convertor'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:777:in `process_result_set'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:775:in `times'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:775:in `process_result_set'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:714:in `fetch_rows'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:251:in `execute'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:651:in `statement'
/path/gems/sequel-4.23.0/lib/sequel/adapters/jdbc.rb:246:in `execute'
/path/gems/sequel-4.23.0/lib/sequel/connection_pool/threaded.rb:103:in `hold'
// doesn't work
val receiveReplica: Receive = withPersistence { (sender, key, id) => sender ! SnapshotAck(key, id) } {
var expectedSeq = 0
{
case Get(key, id) =>
sender ! GetResult(key, kv.get(key), id)
case OperationTimeout(seq) =>
persisting.get(seq).foreach {
case PersistingValue(_, timer, _, _) =>
timer.cancel()
val connection = Http(context.system).outgoingConnection("localhost", 8008)
val request =
RequestBuilding.Get("/repos/mrbrdo/test_repo/pulls")
.withHeaders(
RawHeader("Accept", "application/vnd.github.v3+json"))
async[Unit] {
val response = await(Source.single(request).via(connection).runWith(Sink.head))
response.status match {
case status if status.isSuccess() =>
@mrbrdo
mrbrdo / paypals_ipn_designed_by_noobs.rb
Last active August 29, 2015 14:15
Apparently PayPal lets junior-level interns design APIs used by millions...
def paypal_business_param
# as if the name of this type isn't bad enough
if params[:txn_type] == 'recurring_payment_suspended_due_to_max_failed_payment'
params[:receiver_email]
else
params[:business]
end
end
def paypal_subscr_id_param
-----> Using RVM environment 'jruby-1.7.6@xxx'
Using /home/xxx/.rvm/gems/jruby-1.7.6 with gemset xxx
-----> Creating a temporah
-----> Creating a tempora)
-----> Creating a temporas
From xxx.xxx:mrbrdo/xxx
0974861..9cddaa9 production -> production
-----> Creating a tempora'
-----> Creating a tempora.
-----> Creating a tempora.
User.select_map(:id)
# => [2]
User.select_map([:id, :email])
# => [[2, "user@example.com"]]
User.select_hash(:id, :email)
# => {2=>"user@example.com"}
User.select(:id, :email).naked.all
# => [{:id=>2, :email=>"user@example.com"}]
class Commit < Sequel::Model
end
class Repository < Sequel::Model
one_to_many :recent_commits, :class => 'Commit',
eager_limit_strategy: true,
order: Sequel.desc(:id),
limit: 3
end