Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Sort arbitrarily large collections of data with limited memory usage. Given an enumerable and a sort_by
proc, this gem will break the input data into sorted chunks, persist the chunks, and return an Enumerator
. Data read from this enumerator will be in its final sorted order.
The size of the chunks and the strategy for serializing and deserializing the data are configurable. The gem comes with builtin strategies for Marshal
, MessagePack
and YAML
.
The development of this gem is documented in this post from the Salsify Engineering Blog.
Add this line to your application's Gemfile:
gem 'offline-sort'
And then execute:
$ bundle
Or install it yourself as:
$ gem install offline-sort
arrays = [ [4,5,6], [7,8,9], [1,2,3] ]
# Create a sorted enumerator
sorted = OfflineSort.sort(arrays, chunk_size: 1) do |array|
array.first
end
# Stream results in sorted order
sorted.each do |entry|
# e.g. write to a file
end
The example above will create 3 files with 1 array each, then output them in sorted order. You should try different values of chunk_size
to find the best speed/memory combination for your use case. In general larger chunk sizes will use more memory but run faster.
Sorting is not limited to arrays. You can use anything that can be expressed in a Enumerable#sort_by
block.
Message pack serialization is faster than the default Ruby Marshal
strategy. To enable message pack serialization follow these steps.
gem install msgpack
require 'msgpack'
Requiring MessagePack before you require offline_sort
will automatically enable MessagePack serialization in the gem.
Limitations
The MessagePack serialize/deserialize process stringifies hash keys so it is important to write your sort_by in terms of string keys.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that offline-sort demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.