
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
This gem is for downsampling and "bucketing" time based data. Great for passing data to chartkick
<%= line_chart User.downsample_by(60, :created_at).counts %> # 1 minute buckets
Implemented without any dependencies so you don't need activesupport or activerecord.
Add this line to your application's Gemfile:
gem 'downsampler'
And then execute:
$ bundle
Or install it yourself as:
$ gem install downsampler
DataPoint = Struct.new(:time, :value)
data_points = (1..9).map { |i| DataPoint.new(Time.now + i*20, i)}
downsampled = data_points.downsample_by(1.minute, &:time)
#{
# 2014-08-18 15:01:00 -0400=>
# [#<struct DataPoint time=2014-08-18 15:03:40 -0400, value=1>,
# #<struct DataPoint time=2014-08-18 15:03:20 -0400, value=2>,
# #<struct DataPoint time=2014-08-18 15:03:00 -0400, value=3>],
# 2014-08-18 15:02:00 -0400=>
# [#<struct DataPoint time=2014-08-18 15:02:40 -0400, value=4>,
# #<struct DataPoint time=2014-08-18 15:02:20 -0400, value=5>,
# #<struct DataPoint time=2014-08-18 15:02:00 -0400, value=6>],
# 2014-08-18 15:03:00 -0400=>
# [#<struct DataPoint time=2014-08-18 15:01:40 -0400, value=7>,
# #<struct DataPoint time=2014-08-18 15:01:20 -0400, value=8>,
# #<struct DataPoint time=2014-08-18 15:01:00 -0400, value=9>]
#}
downsampled.sum &:value
#{
# 2014-08-18 15:01:00 -0400=> 6,
# 2014-08-18 15:02:00 -0400=> 15,
# 2014-08-18 15:03:00 -0400=> 24
#}
downsampled.mean { |point| point.value }
#{
# 2014-08-18 15:01:00 -0400=> 2,
# 2014-08-18 15:02:00 -0400=> 5,
# 2014-08-18 15:03:00 -0400=> 8
#}
downsampled.counts
#{
# 2014-08-18 15:01:00 -0400=> 3,
# 2014-08-18 15:02:00 -0400=> 3,
# 2014-08-18 15:03:00 -0400=> 3
#}
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that downsampler 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.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.