Skip to content

Instantly share code, notes, and snippets.


Victor Shepelev zverok

View GitHub Profile
zverok /
Created May 9, 2021
"Unmunch" (linearize) word list from Hunspell dictionary with the help of Spylls library
# This is "unmunching" script for Hunspell dictionaries, based on Spylls (full Python port of Hunspell):
# "Unmunching" (Hunspell's term) is a process of turning affix-compressed dictionary into plain list
# of all language's words. E.g. for English, in the dictionary we have "spell/JSMDRZG" (stem + flags
# declaring what suffixes and prefixes it might have), and we can run this script:
# python path/to/en_US spell
# Which will produce this list:
zverok /
Last active Jan 19, 2020
Example of how Ruby's error formatting breaks Markdown

(Just quick copy-paste into the dialog/GitHub issue.)

Ugh, do you know why am I having undefined local variable or method foo' for main:Object?.. I expected it to work for Logger`.


Ugh, do you know why am I having undefined local variable or method `foo' for main:Object?.. I expected it to work for `Logger`.
View produce.rb
# Just porting examples of .unfold usability from
# Ruby 2.7+ Enumerator.produce (and numbered block args):
# Simple examples:
# 10.unfold { |n| n-1 unless n == 1 }.inspect => [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
p Enumerator.produce(10) { _1 - 1 }.take_while { _1 >= 1 }
#=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
View jruby-vs-refine.rb
module Refinements
refine Object do
def derp
yield self
module A
using Refinements
View infoboxer-list-of-areas.rb
require 'infoboxer'
page = Infoboxer.wikipedia.get('List of urban areas by population')
res = page
.sections(/Urban areas/).tables.first
.rows[1..-1].map { |r|
city: r.cells[2].to_s,
country:, # What you see as Japan on page, in page code looks like {{JPN}}
View gimme_gem.rb
# Small thing for installing gems on-the-fly.
# Useful for "self-contained" scripts, too small to be
# distributed with own Gemfile & README and stuff.
# Usage:
# gimme_gem 'sequel' # Checks OR installs the gem
# Sequel.connect 'mysql://....'
# All credits for managing RubyGems code goes to author
View good_data_frame.rb
# It is show-the-point demo for my article
# "On DataFrame datatype in Ruby"
require 'good_data_frame' # `require': cannot load such file -- good_data_frame (LoadError)
# Initialization (with default index): hashes of column: values
# Values of each column are homogenous
# First and most important thing is "what columns is"
table =
manager: ['Tom', 'Jerry', 'Magda'],
View gist:6785c213fd78430cd423
require 'pp'
class Path <, :end_node, :color, :type)
def to_s
[start_node, end_node, color, type].join(' ')
class Test
View gist:4b42441bbbbc9a319ed7
// до всего - присваиваем темам последовательные индексы
// нумерация раздельная для своих и конкурентов
filter(function(l){return l.is_competitor;}).
forEach(function(l, i){l.number = i});
filter(function(l){return !l.is_competitor;}).
forEach(function(l, i){l.number = i});
View gist:3f458782c8f63ceaddda
build_color_map: function(labels){
var colors = _colors.slice(0),
colors_c = _colors.slice(0);
angular.forEach(labels, function(label){
_color_map_c[label.label] = colors_c.shift();
} else {
_color_map[label.label] = colors.shift();