Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
Boo!

Stanko Krtalić monorkin

👻
Boo!
View GitHub Profile
@monorkin
monorkin / fa-icons-5.15.1.txt
Created Nov 18, 2020
FontAwesome 5.15.1 as character list
View fa-icons-5.15.1.txt
 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 Nov 10, 2020
Stimulus has_many fields_for controller
View _form.slim
= 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 Apr 10, 2019
Registry for Actix SyncArbiter Actors
View sync_registry.rs
/// === 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. <hey@stanko.io>
///
/// Permission is hereby granted, free of charge, to any person
/// obtaining a copy of this software and associated documentation
View shrine_multipart_upload_resolver.rb
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
View shrine_multipart_upload_params.rb
{
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">
]
}
View shrine_multipart_upload.graphql
mutation UploadGalleryImages {
uploadGalleryImages(
galleryID: "some_gallery_id"
images: [null, null]
) {
id
filename
url
}
}
View shrine_direct_upload_example.rb
user.avatar_data_uri = arguments[:input][:avatar][:data]
user.save
View shrine_base64_upload_example.graphql
mutation SetAvatar($data: String, $filename: String) {
updateUser(
id: "some_user_uuid"
input: {
avatar: {
filename: $filename
data: $data
}
}
) {
View shrine_direct_upload_example.graphql
mutation SetAvatar($url: String, $filename: String) {
updateUser(
id: "some_user_uuid"
input: {
avatar: {
filename: $filename
url: $url
}
}
) {
View shrine_direct_upload_example.rb
# This code is license under the MIT license
# Full text: https://opensource.org/licenses/MIT
# Author Stanko K.R. <hey@stanko.io>
# Usage:
# ```ruby
# user.avatar = S3UrlToShrineObjectConverter.call(
# arguments[:input][:avatar][:url],
# name: arguments[:input][:avatar][:filename]
# )