Skip to content

Instantly share code, notes, and snippets.

View varyform's full-sized avatar

Oleh Khomei varyform

  • Ukraine
  • 03:00 (UTC +03:00)
View GitHub Profile
@varyform
varyform / multiple_importmaps.rb
Last active April 3, 2024 21:58
Multiple importmaps
# config/initializers/public_importmap.rb
Rails.application.config.public_importmap = Importmap::Map.new
Rails.application.config.public_importmap.draw(Rails.root.join("config/public_importmap.rb"))
# app/helpers/application_helper.rb
# copied from importmaps replacing javascript_inline_importmap_tag
#
# !!! No longer needed after this change https://github.com/rails/importmap-rails/pull/187
#
# def javascript_public_importmap_tags(entry_point = "application", shim: true)
@varyform
varyform / 2.rb
Created December 7, 2021 11:19
Advent of code 2021 day 6 part 2
fish = Hash.new(0).merge(DATA.read.chomp.split(',').map(&:to_i).tally)
256.times do
-1.upto(8) { |day| fish[day] = fish[day + 1] }
born = fish.delete(-1)
fish[8] += born
fish[6] += born
end
wins = [
# rows
0b000000111,
0b000111000,
0b111000000,
# cols
0b100100100,
0b010010010,
0b001001001,
# diags

Keybase proof

I hereby claim:

  • I am varyform on github.
  • I am varyform (https://keybase.io/varyform) on keybase.
  • I have a public key ASBmTI-kjeMgaHsbQGMwHclPhC7mSW6OEkBKy0RVeGk9Xgo

To claim this, I am signing this object:

@varyform
varyform / register_statistics.rake
Created February 6, 2017 18:39 — forked from jsborjesson/register_statistics.rake
Add more folders to rake stats
task :register_statistics do
require 'rails/code_statistics'
STATS_DIRECTORIES << ['Services', 'app/services']
STATS_DIRECTORIES << ['Services Tests', 'test/services']
CodeStatistics::TEST_TYPES << 'Services Tests'
end
Rake::Task['stats'].enhance [:register_statistics]
@varyform
varyform / generator.rb
Last active August 29, 2015 14:17
SVG extension icon generator
require 'color'
require 'digest/md5'
def generate(extension)
color = Digest::MD5.hexdigest(extension)[0..5]
hsl = Color::RGB.from_html(color).to_hsl
hue = hsl.hue / 360.0
sat = 0.52
lit = hsl.lightness / 100
@varyform
varyform / file_ext.css.scss
Created March 13, 2015 17:11
CSS file extension
// usage:
// .file-extension
// %span TXT
body {
background: #f0f0f0;
padding: 2em;
}
.file-extension {
###
# DO YOU HEAR THE PEOPLE SING? (Uplifting Mix)
# version 1.3 (clearer kick sound)
#
# Converted from CoffeeScript
# Source: https://gist.github.com/11080149
# Usage: coffee -bcp file.coffee
#
# Original from Les Miserables
@varyform
varyform / fib.rb
Created April 17, 2014 21:56
fib with memo
# Fibonacci numbers WITH memoization.
# Initialize the memoization array.
@scratchpad = []
# Calculate the nth Fibonacci number, f(n).
def fibo(n)
if n <= 1
n
else
@varyform
varyform / quantize.js
Created September 17, 2013 11:08 — forked from cwey/quantize.js
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php