All Projects → sudara → Sometimes

sudara / Sometimes

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

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Sometimes

Rando Php
RandoPhp is a open source library that implements random generators (Integer, Char, Byte, Sequences, Boolean) and take random sample from arrays
Stars: ✭ 107 (-45.96%)
Mutual labels:  random
Generatedata
A powerful, feature-rich, random test data generator.
Stars: ✭ 1,883 (+851.01%)
Mutual labels:  random
Nyaya
Random Data Generation and/or Property Testing in Scala & Scala.JS.
Stars: ✭ 165 (-16.67%)
Mutual labels:  random
Fakedata
Haskell Library for producing quality fake data
Stars: ✭ 118 (-40.4%)
Mutual labels:  random
Libchaos
Advanced library for randomization, hashing and statistical analysis (devoted to chaos machines). 🔬
Stars: ✭ 1,619 (+717.68%)
Mutual labels:  random
Jnanoid
A unique string ID generator for Java.
Stars: ✭ 147 (-25.76%)
Mutual labels:  random
Prob.js
Generate random numbers from different probability distributions.
Stars: ✭ 102 (-48.48%)
Mutual labels:  random
Insight
🔮 Easy access to model information for various model objects
Stars: ✭ 197 (-0.51%)
Mutual labels:  random
Gofakeit
Random fake data generator written in go
Stars: ✭ 2,193 (+1007.58%)
Mutual labels:  random
Rocket
ROCKET: Exceptionally fast and accurate time series classification using random convolutional kernels
Stars: ✭ 163 (-17.68%)
Mutual labels:  random
Random Image
随机图片服务
Stars: ✭ 118 (-40.4%)
Mutual labels:  random
Baba Core
Mini-language for creating random text generators.
Stars: ✭ 127 (-35.86%)
Mutual labels:  random
Randomatic
Easily generate random strings like passwords, with simple options for specifying a length and for using patterns of numeric, alpha-numeric, alphabetical, special or custom characters. (the original "generate-password")
Stars: ✭ 149 (-24.75%)
Mutual labels:  random
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+636.36%)
Mutual labels:  random
Nanoid
A tiny, secure, URL-friendly, unique string ID generator for Rust
Stars: ✭ 188 (-5.05%)
Mutual labels:  random
Hyperapp Fx
Effects for use with Hyperapp
Stars: ✭ 105 (-46.97%)
Mutual labels:  random
Pandemonium
Typical random-related functions for JavaScript and TypeScript.
Stars: ✭ 144 (-27.27%)
Mutual labels:  random
Rrt Algorithms
n-dimensional RRT, RRT* (RRT-Star)
Stars: ✭ 195 (-1.52%)
Mutual labels:  random
Qcheck
QuickCheck inspired property-based testing for OCaml.
Stars: ✭ 194 (-2.02%)
Mutual labels:  random
Randomdata
Random data generator
Stars: ✭ 157 (-20.71%)
Mutual labels:  random

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].