• Stars
    star
    201
  • Rank 187,710 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A few hacks n' helpers to make your code more fun and unpredictable.

Sometimes

Build Status

Stop being so black and white. Mix things up a bit and execute code sometimes.

A (very) simple collection of lil' helpers polluting Object namespaces since 2013 because...why the hell not?

Installation

Add this line to your Gemfile:

gem 'sometimes'

And then execute:

$ bundle

Require when needed

require 'sometimes'

Usage

Say something every other time

# executes warm fuzzies 50% of the time
sometimes do
  puts "Hey, you are awesome. You really are."
end

Maybe you want to do something several times, but not always the exact same number of times

# between 4 and 10 boogers made, it's unpredictable!
(4..10).times do
  pick_nose
end

Maybe you want to remind someone of something, but not toooo often (It gets annoying!)

# be annoying, but only 15% of the time
15.percent_of_the_time do
  puts "Howdy, Don't forget to register!"
end

33.percent_of_the_time do
  be_very_polite
end

Share a rare moment with your user

# be really annoying about 5% of the time
rarely do
  puts "How would you like some spammy spam spam!"
end

1.percent_of_the_time do
  puts "Want to see something really cool?"
end

If you can't say something nice, don't say anything at all:

never do
  puts "You're a terrible person"
end

Always remember your manners:

always do
  puts "Thanks for sharing!"
end

Otherwise

Counting precisely is overrated.

# Sometimes increment, sometimes don't
i += sometimes(1)

# 5% of the time add 10, otherwise increment
i += rarely(10, otherwise:1)

Model real life state, like your calendar

# 95% of the time you are in meetings
status = mostly ? "busy" : "free"

# same as above
status = mostly("busy", otherwise: "free")

Why?

This gem was made so alonetone could bit more fun when displaying notices and communicating to our users.

We are human, and have personality. Shouldn't our applications reflect this? Be predictable where it counts. But toss in some spice here and there β€” it is always a good thing.

Versions

Works with ruby 2.7 and higher.

Use version 1.0.0 to support ruby < 2.7 Use version 0.0.2 to support ruby < 2.2

Updating and Releasing this gem

  • Update lib/sometimes/version.rb
bundle && bundle exec rake gemspec
bundle exec rake release

More Repositories

1

awesome-juce

A curated list of JUCE modules, templates, plugins, oh my!
Ruby
538
star
2

alonetone

A free, open source, non-commercial home for musicians and their music
Ruby
344
star
3

pamplejuce

A JUCE audio plugin template. JUCE 7, Catch2, Pluginval, macOS notarization, Azure Trusted Signing, Github Actions
C++
332
star
4

melatonin_inspector

A JUCE module that gives you the ability to inspect and visually edit (non-destructively) components in your UI.
C++
90
star
5

melatonin_audio_sparklines

Sparklines For JUCE AudioBlocks
Python
88
star
6

melatonin_blur

Fast cross-platform CPU blurs and shadows for JUCE
C++
54
star
7

dspjargon

All the jargon you need to understand the world of Digital Signal Processing.
48
star
8

stitches

Stitching together MP3 playback in HTML5 Audio with ES6+
JavaScript
33
star
9

melatonin_perfetto

Use google's perfetto performance tracing in JUCE plugins and apps
CMake
32
star
10

soundmanager2-rails

Easy way to get soundmanager2 as a dep in your rails app
Ruby
9
star
11

melatonin_test_helpers

Catch2 Matchers and test helpers for JUCE AudioBlocks
C++
9
star
12

melatonin_parameters

Parameter behavior and formatting for JUCE
C++
8
star
13

pretty-text

Rails plugin that does one thing: gives you a view helper to generate "pretty text" via rmagick
Ruby
7
star
14

lepilo-rails

Lepilo CMS for rails
Ruby
6
star
15

load_monster_plugin

C++
5
star
16

bach

Info, midi files, analysis of Bach's works
4
star
17

deepjargon

A somewhat snarky but actually useful guide to deep learning. Jargon-free since 2017.
Ruby
4
star
18

fitter_happier

A Rails Plugin for adding a simple health check to your application
Ruby
2
star
19

cmake-includes

CMake include files used by Pamplejuce, the JUCE CMake template
CMake
2
star
20

web-plugin-template

Vue
1
star
21

ey-cloud-recipes

A starter repo for custom chef recipes on EY's cloud platform
Ruby
1
star
22

melatonin_hsluv

C++ JUCE module implementation of the HSLuv/CIELUV color space
C++
1
star