This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# | |
# PROBLEM: | |
# Find the greatest product of five consecutive digits in the 1000-digit number. | |
# | |
# 73167176531330624919225119674426574742355349194934 | |
# 96983520312774506326239578318016984801869478851843 | |
# 85861560789112949495459501737958331952853208805511 | |
# 12540698747158523863050715693290963295227443043557 | |
# 66896648950445244523161731856403098711121722383113 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This snippet allows you to sprinkle your code with #debugger references | |
# even if the ruby-debug gem isn't installed (or there's some other error | |
# encountered loading it). | |
# | |
begin | |
require('ruby-debug') | |
Debugger.start | |
rescue Exception => e | |
unless (Kernel.method_defined?(:debugger)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# | |
# Return an array with all occurrences of 2 or more logically | |
# successive elements replaced with ranges, and disjoint elements | |
# as-is. | |
# | |
# @param [Boolean] sorted | |
# If this parameter can be evaluated as a Boolean 'true' value, the | |
# current array will be copied and the copy sorted before |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- | |
# vim: ts=4:sw=4:noet | |
# | |
function _read_config_file() { | |
local _cfgfile='/dev/stdin' | |
local _section | |
local _varname='CONFIG_HASH' | |
local _line | |
local _key | |
local _value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Long OptionParser descriptions don't get nicely wrapped by it, so | |
# this method does the appropriate fill, wrap, and indent. | |
# | |
# @license Apache 2.0 | |
# | |
# @overload wrap(*args) | |
# @param [Array<Hash,String>] args | |
# The argument list can include multiple strings and hashes. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# -*- coding: utf-8 -*- | |
#-- | |
# Copyright © 2015 Ken Coar | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This function provides for sourcing of shell scripts when moving | |
# into (or out of) a directory. | |
# | |
# If the command exits with a non-zero status, or the working | |
# directory isn't changed, no scripts are processed. | |
# | |
# If the command exits with a 0 status and the current working | |
# directory does change, the previous directory is checked for an | |
# ".on_exit" file. If found, it gets sourced. Similarly, the new WD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 = { | |
:one => 1, | |
:two => 2, | |
:three => 3, | |
} | |
# h1 => { :one => 1, :two => 2, :three => 3 } | |
# | |
# Each key/value pair is passed as a two-element array as the second | |
# block argument -- so you can deconstruct it in the arglist declaration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fedora 29 | |
# rpm -q ruby rubygems | |
ruby-2.5.5-101.fc29.x86_64 | |
rubygems-2.7.6.2-101.fc29.noarch | |
# which gem | |
/usr/bin/gem | |
[root@Helium etc]# gem | |
/usr/share/ruby/yaml.rb:5: warning: It seems your ruby installation is missing psych (for YAML output). | |
To eliminate this warning, please install libyaml and reinstall your ruby. | |
Traceback (most recent call last): |