SPC
SPC
find file,
switch bufferA.
browse files:
MX;
EX<
switch buffer
def paralleln(items : Indexable(T), &block : T -> R) forall T, R | |
results = Array(R).new(items.size) { r = uninitialized R } | |
done = Channel(Exception?).new | |
items.each_with_index do |item, i| | |
spawn do | |
begin | |
results[i] = block.call(item) | |
rescue e | |
done.send e |
class Array | |
# Performs the same function as | |
# flatten, only slower (because it's in Ruby | |
# and .flatten is implemented in C) | |
def slow_flatten(arr = self, result = []) | |
if arr.size > 0 | |
first = arr.first | |
if ! arr.first.is_a? Array | |
result.push(first) | |
else |
# Emily Gorcensky's "obnoxious" fizz-buzz (less-compact version) annotated for non-python geeks. | |
# Explanation via Twitter: https://twitter.com/EmilyGorcenski/status/1228407309656903680?s=20 | |
# If you want to dive into the meanings of how it works: it models fizzbuzz by | |
# computing the isomorphism of the finite cyclic groups of the values of the | |
# fizzes and buzzes and whatnot. | |
# | |
# These abelian groups are mapped to the unit circle in the complex plane and | |
# Represented as roots of unity. Such a interpetation has a polynomial | |
# representation. Therefore, the cartesian product in the isomorphism is | |
# represented as polynomial multiplication. The coefficients of a Polynomial |
#lang sicp | |
; A collection of functions | |
; that can be added to your functions | |
; to have them produce graphviz dot notation | |
; as they're run. | |
; | |
; ;------------- | |
; ; Usage inside functions to be graphed | |
; |
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
class MyJob < ActiveJob::Base | |
queue_as :urgent | |
rescue_from(NoResultsError) do | |
retry_job wait: 5.minutes, queue: :default | |
end | |
def perform(*args) | |
MyService.call(*args) | |
end |
// ==UserScript== | |
// @name Readable Ruby Docs | |
// @namespace https://masukomi.org/ | |
// @version 0.1 | |
// @description make the core description text wider | |
// @author You | |
// @match https://ruby-doc.org/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=ruby-doc.org | |
// @grant GM_addStyle | |
// @sandbox raw |