Skip to content

Instantly share code, notes, and snippets.

View monorkin's full-sized avatar
👻
Boo!

Stanko Krtalić monorkin

👻
Boo!
View GitHub Profile
@monorkin
monorkin / generate_hey_email_pkgbuild.rb
Last active October 18, 2024 08:54
Hey email snap to Arch package update script
require "digest"
require "json"
require "net/http"
require "pathname"
require "shellwords"
require "tempfile"
MAX_REDIRECTS = 10
URL = URI("https://api.snapcraft.io/v2/snaps/info/hey-mail")
HEADERS = { "Snap-Device-Series" => "16" }
@monorkin
monorkin / fa-icons-5.15.1.txt
Created November 18, 2020 15:56
FontAwesome 5.15.1 as character list
 address-book; f2b9
 address-card; f2bb
 angry; f556
 arrow-alt-circle-down; f358
 arrow-alt-circle-left; f359
 arrow-alt-circle-right; f35a
 arrow-alt-circle-up; f35b
 bell; f0f3
 bell-slash; f1f6
 bookmark; f02e
@monorkin
monorkin / _form.slim
Created November 10, 2020 10:57
Stimulus has_many fields_for controller
= f.simple_fields_for :item do |ff|
.row.mt-4
.col-12
label Categories
.preview_images data-controller="has-many-fields-for"
.preview_images__container data-target="has-many-fields-for.container"
= ff.simple_fields_for :taggings do |ff|
= render 'category_tagging_form', f: ff
script type="text/html" data-target="has-many-fields-for.template" data-index-placeholder="new_tagging"
= ff.simple_fields_for :taggings, ff.object.taggings.build, child_index: 'new_tagging' do |ff|
@monorkin
monorkin / sync_registry.rs
Created April 10, 2019 17:41
Registry for Actix SyncArbiter Actors
/// === DESCRIPTION ===
/// This is a naive implementation of a registry for Actix Actors that
/// implement a SyncContext. Using it you can retreive an address for
/// any actor registered with it from any point in your program.
///
/// === LICENSE ===
/// Copyright 2019 Stanko K.R. <[email protected]>
///
/// Permission is hereby granted, free of charge, to any person
/// obtaining a copy of this software and associated documentation
gallery = Gallery.find(arguemnts[:gallery_id])
arguments[:images].map do |file|
# Image has a Shrine uploader attached to `file_data`
Image.create(file: file, gallery: gallery)
end
{
galleryID: "some_gallery_id",
images: [
#<ActionDispatch::Http::UploadedFile:0x000055fb90c6dbd0 @tempfile=#<Tempfile:/tmp/RackMultipart20180131-31-6zkb3i.txt>, @original_filename="b.txt", @content_type="text/plain", @headers="Content-Disposition: form-data; name=\"0\"; filename=\"b.txt\"\r\nContent-Type: text/plain\r\n">,
#<ActionDispatch::Http::UploadedFile:0x000055fb90c6da18 @tempfile=#<Tempfile:/tmp/RackMultipart20180131-31-13i0pio.txt>, @original_filename="c.txt", @content_type="text/plain", @headers="Content-Disposition: form-data; name=\"1\"; filename=\"c.txt\"\r\nContent-Type: text/plain\r\n">
]
}
mutation UploadGalleryImages {
uploadGalleryImages(
galleryID: "some_gallery_id"
images: [null, null]
) {
id
filename
url
}
}
user.avatar_data_uri = arguments[:input][:avatar][:data]
user.save
mutation SetAvatar($data: String, $filename: String) {
updateUser(
id: "some_user_uuid"
input: {
avatar: {
filename: $filename
data: $data
}
}
) {
mutation SetAvatar($url: String, $filename: String) {
updateUser(
id: "some_user_uuid"
input: {
avatar: {
filename: $filename
url: $url
}
}
) {