Solus Linux looks good out of the box and has some good features but lacks the integrations and support of other distros.
Here are some workarounds. Please let me know if they break or you found a better way.
require 'io/console' | |
# Reads keypresses from the user including 2 and 3 escape character sequences. | |
def read_char | |
STDIN.echo = false | |
STDIN.raw! | |
input = STDIN.getc.chr | |
if input == "\e" then | |
input << STDIN.read_nonblock(3) rescue nil |
This benchmark establishes baseline the cost-of-doing-business for using a given interpreted language. It gauges the initialization/teardown overhead before/after the interpreter can actually do any work. Each program is the nearest equivalent of a single exit(0)
command as possible. This is not a general-purpose benchmark, but it's interesting to see how different interpreters behave. The below tests were all run on the same CPU running the noop programs for 200 iterations.
The original impetus was for a project called impel
which was going to be executed in the $PS1
, $PROMPT_COMMAND
,
precmd
, or equivalent where I wanted to avoid adding latency to the command prompt but was ambivalent about the language it was written in. There are certainly other concerns to be had beyond this overhead, it's just one of many things to take into consideration.
# via http://www.megasolutions.net/ruby/Getting-the-size-of-the-terminal-in-a-portable-way-26006.aspx | |
TIOCGWINSZ = 0x40087468 | |
def get_winsize | |
str = [0, 0, 0, 0].pack('SSSS') | |
if STDIN.ioctl(TIOCGWINSZ, str) >= 0 | |
rows, cols, xpixels, ypixels = str.unpack("SSSS") | |
p rows, cols, xpixels, ypixels | |
else | |
puts "Unable to get window size" |
git branch -m master main | |
git fetch origin | |
git branch -u origin/main main |
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { | |
// go complains: "use of builtin recover not in function call" | |
//defer cleanup_broken() |
# | |
# You can do `Object.send :include, Introspection` | |
# Then you can call `.introspect` on anything. | |
# | |
# The `introspect` method returns a hash with information about the receiver | |
# including its Class, the Constants and instance_methods defined inside it. | |
# | |
# The "depth" parameter indicates how deeply it should inspect the object. | |
# By default there is no depth limit. Pass in 1 to just get info on the object itself. | |
# |
class Potato | |
def initialize weight | |
@weight = weight | |
end | |
end | |
def self.Potato *weight | |
Potato.new weight.first || 1 | |
end |
#!/usr/bin/env ruby | |
class Passwerd | |
CHARSETS = { | |
lower: (?a..?z).to_a, | |
upper: (?A..?Z).to_a, | |
number: (?0..?9).to_a, | |
space: [' '], | |
sym1: (?!..?/).to_a, | |
sym2: (?:..?@).to_a, |
firstyear | |
=> "1885-1886" | |
lastyear | |
=> "1884-1885" | |
firstyear > lastyear | |
=> false | |
firstyear.bytes | |
=> [49, 56, 56, 53, 45, 49, 56, 56, 54] |