sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- Download zsh-autosuggestions by
| module FactoryGirl | |
| module Doctor | |
| module FloatDuration | |
| refine Float do | |
| def duration | |
| t = self | |
| format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000) | |
| end | |
| end | |
| end |
| So, let’s flip a coin: if it’s heads, play a drum, if it’s tails, play a cymbal. Easy. We can emulate a coin flip with our one_in function (introduced in the section on randomness) specifying a probability of 1 in 2: one_in(2). We can then use the result of this to decide between two pieces of code, the code to play the drum and the code to play the cymbal: | |
| loop do | |
| if one_in(2) | |
| sample :drum_heavy_kick | |
| else | |
| sample :drum_cymbal_closed | |
| end | |
| require 'net/http' | |
| require 'net/https' | |
| require 'uri' | |
| uri = URI('https://example.com/rest/api/2/1') | |
| Net::HTTP.start(uri.host, uri.port, | |
| :use_ssl => uri.scheme == 'https', | |
| :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| |