Skip to content

Instantly share code, notes, and snippets.

View ArthurN's full-sized avatar

Arthur Nisnevich ArthurN

View GitHub Profile
ArthurN / knapsack.exs
Created February 28, 2024 16:18
Knapsack Elixir
# mostly Copilot generated, have not tested/verified
defmodule ImagePlacement do
def place_images(images, canvas_width, canvas_height) do
# Sort images by size in descending order
sorted_images = Enum.sort_by(images, &image_area(&1), &>=/2)
# Initialize the canvas with the first image
canvas = %{x: 0, y: 0, width: image_width(hd(sorted_images)), height: image_height(hd(sorted_images))}
ArthurN /
Created May 17, 2023 15:47
Long-running ContainerFit POC

Long-running ContainerFit session

Install screen (if not already installed)

On Ubuntu/Debian: sudo apt install screen

On Red Hat: sudo yum install screen

Kick off ContainerFit

ArthurN / pipeline.yml
Created May 11, 2023 04:20
Fitstack - Azure Pipeline Example
- main
vmImage: 'ubuntu-latest'
imageName: 'your-app-image'

Keybase proof

I hereby claim:

  • I am arthurn on github.
  • I am arthurn ( on keybase.
  • I have a public key ASAMIYJVK2x339Jmc7L8QypS9XFOTA2qZbvqdJ7LkKakWQo

To claim this, I am signing this object:

ArthurN / BootstrapMultiselect.vue
Created January 24, 2018 15:28
Vue wrapper for jquery bootstrap multiselect
<template lang='slm'>
select.form-control multiple="multiple"
option v-for="option in selectOptions" :value='option.value' {{ option.label }}
export default {
name: 'bootstrap-multiselect',
props: {
selectOptions: {
ArthurN /
Last active July 2, 2020 07:29
From pow to puma-dev on macOS keeping .dev domains
# Why:
# 1) Chrome 63 (Dec 8) breaks .dev domains by forcing HTTPS:
# 2) Pow is at EOL, superceded by puma-dev (see, 6 Version History, 0.6.0, Dec 8 2017)
# Uninstall pow
curl | sh
# If you use powder, you can remove it as well
gem uninstall powder
module ChronicDateProperty #:nodoc:
extend ActiveSupport::Concern
module ClassMethods
# Define a Reform property which coerces its input via the Chronic parser.
def chronic_date_property(*args)
options = args.extract_options!
field = args.first
property(field, options)
ArthurN /
Created August 24, 2015 18:51
Kill Duplicate Sidekiq processes
if [ $(pgrep -f sidekiq | wc -l) -gt 1 ]; then
kill $(pgrep -f sidekiq | grep -v $(pgrep -of sidekiq) | sort -n | uniq | awk '{printf $1" "}');
ArthurN / gist:e980d723a6d63e9fc766
Created November 22, 2014 01:21
def get_fields
# We have to use #send because AFAIK, PDF::Reader does not expose the root object anywhere
acroform = @reader.send(:root)[:AcroForm]
# PDF::Reader encapsulates each piece of PDF data in #objects. The field_refs are really references to
# these objects. We iterate through and de-reference the actual object, creating a AcroField based on its
# data
field_refs = @reader.objects[acroform][:Fields] unless acroform.nil?
fields = do |field_ref|[field_ref])
ArthurN / gist:f16ad0e6958a0af73d39
Created November 10, 2014 21:08
AWS permissions
# From
"Statement": [
"Sid": "AllowPublicRead",
"Action": [